Bootstrap collapse - go to top of the open item?

前端 未结 6 1668
孤街浪徒
孤街浪徒 2021-02-01 07:48

I\'m using the bootstrap collapse function, but when I open an element which has a lot of content, then open the next element, it jumps down and doesn\'t go to the top of the op

6条回答
  •  孤街浪徒
    2021-02-01 08:36

    The event name has changed in Bootstrap 3, so @bboymaanu's won't work as shown. It should use the 'shown.bs.collapse' event instead.

    $(".accordion-body").on("shown.bs.collapse", function () {
        var selected = $(this);
        var collapseh = $(".collapse.in").height();
        $.scrollTo(selected, 500, {
            offset: -(collapseh)
        });
    });
    

    The new events are documented here.

提交回复
热议问题