On click slidetoggle div but hide others first - jQuery

后端 未结 5 1833
太阳男子
太阳男子 2021-02-06 13:06

I have a page that when a user clicks a title, the following div toggles display.

I want to somehow say if any other divs are display:block then set them to display non

5条回答
  •  闹比i
    闹比i (楼主)
    2021-02-06 13:53

    is not a valid closing. The closing should be

    Title

    sadasd

    Title

    sadasd

    Title

    sadasd

    CSS:

    .office
    {
        display: none;
    }
    

    and jquery:

    $(function () {
        $('.office-title').click(function () {
            $(this).next('div').slideToggle();
    
            $(this).parent().siblings().children().next().slideUp();
            return false;
        });
    });
    

    HERE YOU CAN CHECK

提交回复
热议问题