I want to remove the span using jQuery,
I have tried the .unwrap(); but it’s not working.
<div>
<ul>
<li><a href="#"><span>link</span></a></li>
<li><a href="#"><span>link</span></a></li>
</ul>
</div>
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Obviously,
unwrapdoesn’t work as thespans only have text nodes inside them and jquery doesn’t handle text nodes too well… this works however (you could use alsojQuery.textinstead ofjQuery.htmlif you’re sure that thespanonly contains text):Working example
Edit: Actually, it seems that
unwrapworks as well if you usejQuery.contentsto work around the jquery’s inability to directly select text nodes: