JQuery change inner text but preserve html

前端 未结 14 2775
名媛妹妹
名媛妹妹 2020-12-01 06:56

I would like to change the text of a HTML element but preserve the rest of the inner html with jQuery.

For instance:

Some         


        
14条回答
  •  醉话见心
    2020-12-01 07:40

    try this code

    $('a').live('click', function(){
        var $img = $(this).find('img'); 
        $(this).text('changed');
        $(this).append($img);
    });
    

提交回复
热议问题