Cycle through divs?

后端 未结 2 656
旧巷少年郎
旧巷少年郎 2021-01-07 06:08

I have this HTML:

first box
second box
2条回答
  •  温柔的废话
    2021-01-07 06:44

    $('a').click(function() {
        var visibleBox = $('#container .boxes:visible');
        visibleBox.hide();
        var nextToShow = $(visibleBox).next('.boxes:hidden');
        if (nextToShow.length > 0) {
            nextToShow.show();
        } else {
            $('#container .boxes:hidden:first').show();
        }
        return false;
    });
    

    Live demo.

提交回复
热议问题