can any one help me with this jquery, i need to remove tags inside other tags eg if a p tag is inside an h1 tag remove the p tag but keep the content, I have tried a few ways but the best i can come up with is to remove the content as well
$("#textEditor").contents().find("h1:has(p)").find("p").remove();
Edit here is the mark up i would like to validate
<h1>This is an example <strong> of bad markup</strong>
<p>need to remove these p tags but keep content</p></h1>
Use
unwrap()to remove a tag, but keep it’s content in the DOM. Also, your call to thecontents()function isn’t required.More details on unwrap()