How to remove only tag using jQuery?

前端 未结 5 1733
心在旅途
心在旅途 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:51

    Unwrap should work. It's possible you're not successfully selecting the span which you wish to unwrap. You can try the following code which should select that span successfully:

    $("li a span").unwrap()
    

    It's a bit unclear from your question what exactly you're trying to do. It's also unclear whether you're having trouble with the selectors or with the jquery api. To get a better handle on jquery's selectors I recommend you install firebug and firequery, as it can really help you understand what you're selecting.

提交回复
热议问题