Using Jquery To Clean Up Html Code?
Using jQuery, does anyone know how I can clean this markup:
Solution 1:
Solution 2:
You could also do this:
$('span').each(function() {
if($(this).prop('tagName') == $(this).children(":first").prop('tagName')) {
$(this).children(":first").unwrap();
}
});
Solution 3:
It is not a jQuery solution, but I don't know if you need it to live process your HTML. Otherwise you could use this online tool: http://www.dirtymarkup.com/ it will transform your code:
<spanstyle="font-size:19px"><spanstyle="font-size:20px"><spanstyle="font-size:21px">
Something
</span></span></span>
into:
<spanstyle="font-size: 19px">Something</span>
Post a Comment for "Using Jquery To Clean Up Html Code?"