How to get with JavaScript the rows count of a HTML table having id and name?
How to get with JavaScript the rows count of a HTML table having id
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Given a
and a
there are two ways to count the rows:
The
table.rows.lengthreturns the amount of ALL<tr>elements within the table. So for the above table it will return5while most people would really expect3. Thetable.tBodiesreturns an array of all<tbody>elements of which we grab only the first one (our table has only one). When we count the rows on it, then we get the expected value of3.