Reputation: 21
i have a problem, my code works 100% fine on Chrome and what it does is it gets the text and value from in table rows but as soon as it goes to IE it stops working and i have narrowed it down to childNodes here is a quick sample of the code that doesn't work in IE:
var t = document.getElementById('tableFull');
for (var i = 1, row; row = t.rows[i]; i++) {
var tee = t.childNodes[3].childNodes[i].rowIndex;
var subtractCost =t.childNodes[3].childNodes[i].childNodes[1].childNodes[1].innerHTML;
var subtractName = t.childNodes[3].childNodes[i].childNodes[0].childNodes[0].innerHTML;
}
Anyone know how i can replace the childNodes here for IE?
Upvotes: 0
Views: 3089
Reputation: 171
The counting of childNodes varies. Some browsers include empty textNodes, some do not. In this sort of operation as I believe you are describing, it is better to use the parent's getElementsByTagName()
method. That way the number of chidren and index of each child you are looking for will be consistent.
Or You Can try .children
instead of childNodes
Hope this will help
Upvotes: 1