简体   繁体   中英

How to fix jQuery submenu accordion using nextUntil() and not()?

I'm trying to use jQuery's nextUntil() but the other parent divs are closing when I click the child divs. I wanted to use the .not() before the nextUntil function.

I'm trying to achieve a correct way of hiding and showing child divs. Thanks

$('.content').click(function() {
    $(this).not('.head').nextUntil('.content').toggle('slow');
    $('.subcontentchild').hide();

    return false;
});

http://jsfiddle.net/pys5T/8/

You can specify multiple selectors separated by , :

$('.content').click(function() {
    $(this).nextUntil('.content,.head').toggle('slow');
    $('.subcontentchild').hide();

    return false;
});

See updated fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM