jQuery: nextAll() then jump to next div

I’m trying to use jQuery’s nextAll() across multiple divs:

<div class='divA'>
    <span class='a b'></span>
    <span class='a'></span>
    <span class='a b'></span> [B][COLOR="Red"](Start searching for next 'b' class)[/COLOR][/B]
    <span class='a'></span>
    <span class='a'></span> [B][COLOR="Red"](No more 'b' classes are found)[/COLOR][/B]
</div> [B][COLOR="Red"](So jump to next div)[/COLOR][/B]
<div class='divA'>
    <span class='a'></span>
    <span class='a b'></span> [B][COLOR="Red"](And find this one)[/COLOR][/B]
    <span class='a'></span>
    <span class='a b'></span>
    <span class='a'></span>
</div>

Any Ideas?

Try this, i haven’t tested it but it should work.

$('.divA').each(function() {
    $('span', this)
        .nextAll()
        .hasClass('b')
        .css('background-color', 'red');
});

Well it didn’t work for my particular application but it did lead me to a solution, and I should at least thank you for that :slight_smile:

No worries, if it helped get you a solution im happy.