I get the weirdest Javascript issues in Firefox today.
I am trying to manipulate some rows of a table, but .getElementsByTagName("tr");discarding unwanted files.
dynamicTable.tableBody = dynamicTable.getElementsByTagName("tbody")[0];
var tableRows = dynamicTable.tableBody.getElementsByTagName("TR");
var actualTableRows = new Array();
for(var i in tableRows) {
var row = tableRows[i];
alert(row.tagName);
if(row.tagName == "TR"){
actualTableRows.push(row);
}
}
dynamicTable.bodyRows = actualTableRows;
The obscure part, of course, is my temporary hack to fix the error. For some reason, it .getElementsByTagName("tr")also discards some functions.
In this case, the warning above looks something like this: TR TR TR TR undefined undefined undefined ".
The code I wanted was something like this
dynamicTable.bodyRows = dynamicTable.tableBody.getElementsByTagName("tr");
But then it bodyrowsdoes not contain only <tr>elements, it has the aforementioned garbage in it.
Any thoughts?
: , 24 , 21 (tr ). - , .
alert(row), :
[object HTMLTableRowElement]
...
function item() {
[native code]
}
21
function namedItem() {
[native code]
}