javascript - 'sibiling' 和 'not' 选择器出现问题

标签 javascript jquery jquery-selectors

我的页面看起来像这样

<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');

http://jsbin.com/ipuvix/3/

关于javascript - 'sibiling' 和 'not' 选择器出现问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14487202/

相关文章:

javascript - 无法弄清楚我的 Javascript 程序的控制流程

javascript - 计算 header 类之前和之后的所有 Item 类元素

javascript - 如何在段落中找到一个不强的元素

javascript - 在 Firefox 插件中覆盖原型(prototype)方法时 XrayWrapper 错误(值可调用)

javascript - 如何使用 Angular 动态更改css类

javascript - 按住按钮可在 Android PhoneGap 中执行操作

Jquery 非选择器难度

javascript - 获取动态输入区jquery中的post数组插入批量codeigniter

覆盖/覆盖/堆叠元素上的 Javascript 鼠标事件

jquery - 如何更改 Duotive slider 以使用 CSS3 背景尺寸封面