I'm coding an application that adds rows to a table without refresh using javascript and jquery. In order to append to the table, I need to do a count of the rows that are currently in the table. I'm using this code...
var count = $('#columns tr.FIELD').length;
The code works fine in Firefox and Chrome, but I am required to build around IE7. Is there any reason that IE returns a count of 0 w开发者_JAVA百科hile this selector works fine in other browsers?
Thanks.
I think IE7 might be inserting a hidden tbody
tag in your table, which causes the selector to be incorrect.
Try $('#columns').find('tr.FIELD').length
More appropriately, make sure your table is semantically correct
<table>
<thead>[HEADER ROW]</thead>
<tbody>[CONTENT]</tbody>
</table>
精彩评论