prepend problems! What's going on here?!
so I'm trying to dynamically build a table based on a checkbox being checked in the first td of every tr:
-
var tableID;
var isChecked;
var tableImportBuild;
function importData(id) {
tableID = "tbl" + id;
isChecked = $('#' + tableID).find('tbody input:checked');
tableImportBuild = "<table cellpadding='0' cellspacing='0' border='0'></table>";
$(isChecked).each(function() {
var row = $(this).parent().parent().clone();
$(tableImportBuild).prepend($(row));
});
$('body').append($(tableImportBuild));
//alert($(tableImportBuild).html());
}
I'm just appending to the body to see what happens. Alerting $(tableImportBuild).html() returns nothing, however it does append the table with nothing inside to the body.
I should note that isChecked points to a checkbox inside a table cell. I'm trying to clone the entire row the checked checkbox is in. If I alert $(tableImportBuild).html() from within the each loop I do get the result I was expecting but for some reason I don't have access to that variable once outside the loop. Either that or I'm doing something wrong...
Any ideas?