0

I have this DOM

<div class="c">c</div>
<div class="a">match me not</div>
<div class="c">c</div>
<div class="c wrapper">c with some .wrapper</div>
<div class="a">match me!</div>
<div class="a">match me!</div>
<div class="c">c</div>
<div class="a">match me not</div>
<div class="c">c</div>

and need to match .a after .wrapper until the next .c

nextAll() matches everything after

nextUntil() only selects the last element

Test: http://jsfiddle.net/d4sSs/1/

Martin
  • 2,007
  • 6
  • 28
  • 44

2 Answers2

1

Try this:

$(".wrapper").nextUntil('.c').addClass("matched");

http://jsfiddle.net/PAUQ6/

Jason P
  • 26,984
  • 3
  • 31
  • 45
1

USe like this way

$(".wrapper").nextUntil('.c').filter(".a").addClass("matched");

Demo

Anoop Joshi P
  • 25,373
  • 8
  • 32
  • 53