How to remove only tag using jQuery?

前端 未结 5 1837
心在旅途
心在旅途 2021-02-06 00:23

I want to remove the span using jQuery, I have tried the .unwrap(); but it\'s not working.


      
5条回答
  •  感动是毒
    2021-02-06 00:39

    $('li').find('span').remove();
    

    or

    $('li').find('span').detach();
    

    If you want to remove the wrapping only, try

    var buffer = $('li').find('span').text();
    $('li').find('span').parent().html(buffer);
    

提交回复
热议问题