86
rated 0 times
[
88]
[
2]
/ answers: 1 / hits: 9370
/ 11 Years ago, sun, february 2, 2014, 12:00:00
I have a JS function that takes a 2D array and a div. It creates a table from the array and appends it to the div. The div currently displays: [object HTMLTableElement]. How can I display it as the table instead?
I call the function with: createTable(myArray, $(#tblDiv));
.
Later:
function createTable(array, tableDiv)
{
var tbl = document.createElement('table');
tbl.style.border = 1px solid black;
for(var i = 0; i < array.length; i++)
{
var tr = tbl.insertRow();
for(var j = 0; j < array[i].length; j++)
{
var td = tr.insertCell();
}
}
tableDiv.append(<br> + tbl);
return;
}
More From » jquery