1

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

mm2000
  • 23
  • 6
  • FYI, IDs must be unique (refering to your jsFiddle) – A. Wolff Nov 19 '13 at 09:34
  • Maybe you wanted `jQuery(this).nextUntil('div.level3').slideToggle(300);` ? This will get all elements next to current untill div with class 'level3' – Vit Kos Nov 19 '13 at 09:36
  • A. Wolff I have unique IDs and Vit Kos ur method toggles my .level2 without showing any .level3 – mm2000 Nov 19 '13 at 09:44

1 Answers1

3

Try

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

Demo: Fiddle

Arun P Johny
  • 384,651
  • 66
  • 527
  • 531