How do i Wrap a table in a div?
I’m using $(“table”).each(function() to locate the tables i then need to enclose it in a div this is a snippet of my code tNum is just a sequential number to give the div a unique id
var strToAppend = "<div>Blah Blah</div>
$(this).wrap(function(){
return "<div class = 'tabDiv' id='tabDiv' + tNum +">" + $(this) + "</div>" + strToAppend;
});
this crates [object Object] before the table but no strToAppend
[object Object] is seen in the web page
What am i doing wrong?
It seems that your aims could be achieved with the following, which perhaps looks more complex than your append a string, but is still quite simple:
JS Fiddle demo.
References:
each().parent().text().wrap().