开发者

how to select th with no colspan in IE

开发者 https://www.devze.com 2023-01-11 04:32 出处:网络
I am using this code to get all the tableheads which do not have colspan. It only works in firefox and chrome, but not in IE. What is the equivalent code for IE? thanks.

I am using this code to get all the tableheads which do not have colspan. It only works in firefox and chrome, but not in IE. What is the equivalent code for IE? thanks.

$tableHeaders = 开发者_StackOverflow中文版$("thead th:not([colspan])", table);


This is related to a known bug: http://bugs.jquery.com/ticket/7234

This is what I come up with, to have a cross-browser workaround:

Compatible IE7,IE8,IE9,FF4,Chrome,Opera11:

.filter(":not([colspan]),[colspan='1']")

But be carreful, this will also select td/th cells with a colspan attribute setted manually to 1, like ... [This doesn't append in my code because I remove the colspan attribute if setted to value 1]

So I guess this is what you're looking for:

$tableHeaders = $("thead > th", table).filter(":not([colspan]),[colspan='1']");

Notice I've added a '>' to the th selector to avoid selecting other th you might have inside (table inside your table header, why not?).


Try:

$tableHeaders = $("#table_id th:not(:has(colspan))");

More:

http://api.jquery.com/has-selector/

0

精彩评论

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