mm2000
mm2000

Reputation: 23

jQuery nested loop nextUntil selector

So I basically have the following files and html document

jQuery(function () {
jQuery(".jx_form_Annuairecommunal").click(function () {
    jQuery(this).nextUntil().find('.level3').slideToggle(300);
    return false;
});
});

my problem is that im not being able to stop the accordion effect to the next .level0.level2

My nextUntil() function doesnt end where desired and so it expands the whole accordion with all .level3 open

Thx for ur helpful answers in advance

Upvotes: 1

Views: 445

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388396

Try

jQuery(function ($) {
    $(".jx_form_Annuairecommunal").click(function () {
        $(this).nextUntil('.jx_form_Annuairecommunal:has(.level0 .level2)').find('.level3').slideToggle(300);
        return false;
    });
});

Demo: Fiddle

Upvotes: 3

Related Questions