javascript - Strip specific span tag from HTML content Jquery -
i have following html string , , need strip out specific span tags(those pre attribute), retain span contents
"<p>it <span class='pre="it' ?>is is</span> movie</p>" i need following output,
"<p>it is movie</p>"
well, first should try tu use valid html. can use code :
$("<p>it <span class='pre'>is is</span> movie</p>") .find('span') //used 'span' here since you'll change class name .contents() .unwrap() .parent(); from jquery doc :
the .unwrap() method removes element's parent. inverse of .wrap() method. matched elements (and siblings, if any) replace parents within dom structure.
you need target content of span unwrap span itself.
Comments
Post a Comment