Counting the number of rows in an HTML table except don't count the <th></th> as a row
问题 I need your help, if the following code below counts every table row in a table, how can it be amended such that the code won't count the <th></th> as a row itself? var rows = document.getElementById("data").rows.length; 回答1: You should be using thead and tbody HTML: <table id="data"> <thead> <tr><th>Hz</th></tr> </thead> <tbody> <tr><td>1</td></tr> <tr><td>2</td></tr> <tr><td>3</td></tr> </tbody> </table> JavaScript: var rows = document.getElementById("data").getElementsByTagName("tbody")[0]