I'm trying to remember the syntax for getting an element inside a table using JavaScript. I have a table with a checkbox in it. These are dynamic checkboxes or i would just use the getElementById. Here is how I'm doing it. I know I'm close, 开发者_如何转开发but just figured it out yet. Here is the code I have so far:
table_name.rows[0].cells[0].item[0]
or
tbl_run_avail.rows[1].cells[0].elements[0]
Since you're using DOM Level 0, you're probably looking for the childNodes property:
table_name.rows[0].cells[0].childNodes[0];
The above assumes that the check box is the very first child node of your table cell. In this situation, you can avoid unnecessary indexing by using the firstChild property:
table_name.rows[0].cells[0].firstChild;
It's easy if you use the children
property:
yourTable.rows[0].cells[0].children[0];
精彩评论