我的页面看起来像这样
<h4></h4>
<table></table> < want this
... < want all these tables
<table></table> < want this
<h4></h4>
<table></table> < not this
... < not these
<table></table> < not this
我试图仅选择第一个 <h4>
下的表使用此 jQuery 选择器的元素
$("h4:eq(0) ~ table.someClass:not(h4:eq(1) ~ table.somaClass)")
它不起作用 - 返回所有表。
最佳答案
使用 div
获得更简单的测试用例:
$('h4:first').nextUntil('h4').filter('div').css('background', 'green');
关于javascript - 'sibiling' 和 'not' 选择器出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14487202/