I have the following markup generated dynamically with a 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 the elements that do not have class "good" on. Get something like this:
<span>
T <em class="good" style="position: relative;">H</em> ES
</span>
I figured that I can use the unwrap 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