So I have a table that includes hidden items. There's a button that a user can press, and it'll wipe all of the table rows. However, I want to save the hidden elements and append them to the new table.
I tried this to do accomplish that:
var hidden_items = $("input[type='hidden']");
var html = "";
for ( var i = 0, l = hidden_items.length; i < l; i++ ) {
if (hidden_items[i].closest("tbody") !== null) {
html += hidden_items[i]
}
}
The reason I'm doing .closest("tbody") is because there are other hidden inputs on the entire page, and I just want to save the ones that are in the table.
When I do this, the content of html turns out to be nothing but this:
"[object HTMLInputElement][object HTMLInputElement][object HTMLInputElement][object HTMLInputElement][object HTMLInputElement][object HTMLInputElement][object HTMLInputElement][object HTMLInputElement][object HTMLInputElement]"
What am I doing wrong? If I do a console.log(hidden_items[i]) then it actually spits out the correct stuff to the console, so why can't it append to the html string properly?