I am trying to convert the HTML of a basic table into a basic <section>
tag. I am having trouble iterating each table, and the "content" div is being repeated into each section. See my fiddle:
$(document).ready(function() {
var section = $("<section>");
$("table").each(function(){
$("td").each(function(){
var content = $('<div class="content">').html(this.innerHTML);
section.append(content);
});
$("table").replaceWith(section);
});
});
The results I need is:
<section>
<div class="content">
<h2>About</h2>
</div>
</section>
<section>
<div class="content">
<h2>Services</h2>
</div>
</section>
I know it's probably really easy and just a matter of iterating the sections/tables correctly, but I just can't seem to get it right. Thanks in advance!