开发者

Selector to return closest <tr> only if table has more than 2 rows

Is there a selector available in jQuery to do something like:

$(this).closest('tr:count(tr>2)');

Context of this is an <input> element within a <td>.

Disclaimer: I know this can be开发者_JAVA百科 done with .length .size .filter .not etc but I wonder if there is a nice way to do this just using CSS selectors.


Didn't test, but probably

$(this).closest('tr:not(:only-child)')

assuming a tr will only have tr sisters, which is not unreasonable.


Put your header in a <thead> and your rows in a <tbody>, as they should be. That way a simple selector such as tbody:has(tr)>tr or the one given by @Amadan will work.

(Ok, I didn't quite think that selector through...)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜