I have the following markup generated dynamically with split and join function
<span>
<em style="position: relative;">T</em>
<em class="good" style="position: relative;">H</em>
<em style="position: relative;">E</em>
<em style="position: relative;">S</em>
</span>
I want to remove the em tag for elements that do not have a good class. Get something like this:
<span>
T <em class="good" style="position: relative;">H</em> ES
</span>
I realized that I can use the spread for this, but it does not work:
$(document).ready(function(){
$("#njoin").live('click', function(){
$('em').each(function() {
if ($(this).hasClass('good')) {
$('.good').unwrap();
}
});
});
});
What should I do to make it work? thank you
source
share