How to get an HTML table rows count if we do not have tbody on HTML layout?

 Posted by vishalneeraj-24503 on 12/2/2014 | Category: JavaScript Interview questions | Views: 1763 | Points: 40
Answer:

Write below code:-
var table_rows_cnt = document.getElementById('your_table_id').getElementsByTagName("tr").length;

alert(table_rows_cnt);

Or you can also write:-
var table_rows_cnt = document.getElementById('your_table_id').rows.length;

alert(table_rows_cnt);


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response