Entry
How do I find all the rows in a TABLE?
How do I find all the rows in a TABLE?
How do I find all the rows in a TABLE?
Mar 10th, 2000 04:06
Martin Honnen,
Only IE4+ and NN6 through their full DOM implementation allow that.
Every HTMLTableElement has a property
rows
which contains all the HTMLTableRowElements in the table. So you get a
reference to a table
var table =
document.all ? // IE
document.all['tableID'] :
document.getElementById ? // NN6 or other DOM compliant browser
document.getElementById('tableID') :
null; // no access
and then you script table.rows for instance
if (table) // browser supports TABLE access
// use table.rows for instance color rows alternatingly
for (var r = 0; r < table.rows.length; r++)
if (r % 2 == 0)
table.rows[r].bgColor = 'red';
else
table.rows[r].bgColor = 'green';
NN4 doesn't provide DOM access to TABLE elements nor to TABLE rows (TR
elements).
http://www.faqts.com/knowledge-base/view.phtml/aid/979/fid/192/lang/en
http://www.faqts.com/knowledge-base/view.phtml/aid/980/fid/192/lang/en
show how to use layers to achieve nevertheless onmouseover/out/click
handling for table cells and table rows.