开发者

jQuery - Counting table rows not working in IE7

开发者 https://www.devze.com 2023-01-10 16:10 出处:网络
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\'

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>
0

精彩评论

暂无评论...
验证码 换一张
取 消