jQuery selectors: logical OR

前端 未结 6 1869
我在风中等你
我在风中等你 2021-01-03 19:08

I can\'t seem to see the forest for the trees right now (Looked at the api docs already).
It has to do with jQuery selectors: What I\'m trying to do is to select all ele

相关标签:
6条回答
  • 2021-01-03 19:30

    It's the same as in CSS selectors:

    $('.headsection, .subtitle');
    
    0 讨论(0)
  • 2021-01-03 19:35

    What about: $some_elements.eq(0).nextUntil('.headsection, .subtitle');

    Works for me at least. Read about multiple selectors.

    0 讨论(0)
  • 2021-01-03 19:42

    Would the multiple selector work for what you're doing? Api doc is here.

    0 讨论(0)
  • 2021-01-03 19:47

    Just separate them with a comma:

    $content = $some_elements.eq(0).nextUntil('.headsection, subtitle');
    
    0 讨论(0)
  • 2021-01-03 19:48

    You don't really need a logical OR as such, $('.headsection, .subtitle') should do the job.

    0 讨论(0)
  • 2021-01-03 19:49

    jQuery uses the CSS selector syntax, so if you know that, just put the same selectors into jQuery and bob's your metaphorical uncle. jQuery uses the sizzle selector engine which supports virtually all CSS3 selectors :)

    As everyone has already said - the way to do it is this: $content = $some_elements.eq(0).nextUntil('.headsection, subtitle');

    0 讨论(0)
提交回复
热议问题