让 jQuery 选择器更加简洁
有没有办法更简洁地表达下面的 jQuery 选择器?
$this
.children('div[name][class="array"],div[name][class="object"],input[name][value]')
.each( ... );
粗略地说,这个选择器所做的就是选择满足以下逻辑条件的 $this
的直接子代:
('div' AND '[name]' AND '[class="array"]')
OR
('div' AND '[name]' AND '[class="object"]')
OR
('input' AND '[name]' AND '[value]')
我想要一个选择器来选择 $this
的直接子代> 满足以下等效逻辑条件:
'[name]' AND (('input' AND '[value]') OR
('div' AND ('[class="array"]' OR '[class="object"]')))
不,我不想想要连续调用.filter()
。
Is there any way to express the following jQuery selector more succinctly?
$this
.children('div[name][class="array"],div[name][class="object"],input[name][value]')
.each( ... );
Roughly speaking, what this selector does is pick the immediate children of $this
that satisfy the following logical condition:
('div' AND '[name]' AND '[class="array"]')
OR
('div' AND '[name]' AND '[class="object"]')
OR
('input' AND '[name]' AND '[value]')
I would like to have a selector that picks the immediate children of $this
that satisfy the following equivalent logical condition:
'[name]' AND (('input' AND '[value]') OR
('div' AND ('[class="array"]' OR '[class="object"]')))
And no, I do NOT want to make successive calls to .filter()
.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)