I just want to replace all <p> tags with <tr>
function test() {
$("p").each(function(index) {
var htmlStr = $(this).html();
$(this).replaceWith("<tr>" + htmlStr + "<\/tr>");
});
}
It’s not working. the replacement does work but the html content of the <p> tags is removed. so the output would be something like <tr></tr>
Also, this function will go through all the entire html page, right ? I just want it to be processed on my #content_div. Is there anything I should add or before $("p") ?
That’s because
<TR>can’t contain anything other than<TH>or<TD>. jsFiddle