1

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]

2 Answers 2

1

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;
Sign up to request clarification or add additional context in comments.

Comments

0

It's easy if you use the children property:

yourTable.rows[0].cells[0].children[0];

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.