Reputation: 27648
I would like to use jquery to remove some tags inside mainclass, so that this -
<div class='mainclass'>
<div class='inclass'>
<a href='#'>Some text</a>
</div>
</div>
Becomes this -
<div class='mainclass'>
Some text
</div>
Thanks in advance.
Upvotes: 0
Views: 185
Reputation: 16808
Store the text you want to preserve, remove the elements and set the text to the main div.
var sometext = $('.mainclass > .inclass > a').text();
$('.mainclass').remove('.inclass').text(sometext);
Upvotes: 0