I need to replace
<span class='foo'>bar</span>
with
bar
using JavaScript / jQuery.
Note: tag content must be inserted exactly in the same place, where tag was.
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.
One plain JavaScript approach is the following:
JS Fiddle demo.
Edited the function in order to cache the
el.parentNode(since I’m using it twice):JS Fiddle demo.
Also, again an update to the function, to use
replaceChild()rather thaninsertBefore()andremoveChild():JS Fiddle demo.