function toText()
{
var convertHTML =$('#mainContent').html();
var ele = $(convertHTML + " > span").each(function(){
$(this).replaceWith($(this).text());
});
console.log(ele);
}
My aim is to replace the following content
<div id="mainContent">
test
<br>
1234
<br>
<span class="underline">test</span>
<br>
<span class="underline">1234</span>
</div>
And want my function to output test <br> 1234 <br> test <br> 1234
This is why i cant just use text() as it takes away the <br> aswell!