jQuery选择器:逻辑OR

Ram*_*No5 27 jquery css-selectors jquery-selectors

我现在似乎无法看到森林中的树木(已经看过api文件).
它与jQuery选择器有关:我要做的是选择所有具有类subtitle或者的元素headsection.像这样的东西:$('.headsection || .subtitle');

更具体一点:我想将此选择器与函数一起使用nextUntil.

$content = $some_elements.eq(0).nextUntil('.headsection || subtitle');
Run Code Online (Sandbox Code Playgroud)

据我所知||,jQuery的选择器中没有.那么实现这一目标的最佳方法是什么?

谢谢你的帮助!

Bla*_*ura 52

它与CSS选择器中的相同:

$('.headsection, .subtitle');
Run Code Online (Sandbox Code Playgroud)


Fel*_*ing 29

关于什么: $some_elements.eq(0).nextUntil('.headsection, .subtitle');

至少对我有用.阅读多个选择器.


Jus*_*ier 5

只需用逗号将它们分开:

$content = $some_elements.eq(0).nextUntil('.headsection, subtitle');
Run Code Online (Sandbox Code Playgroud)


Ste*_*eve 5

您实际上并不需要逻辑或,$('.headsection, .subtitle')应该完成这项工作。