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
$(".accordion-body").on("shown", function () { var id = $(this).attr('id'); $('html, body').animate({scrollTop: $('#'+id).offset().top + -50}, 1000); }); });
Simple Example. The ".top + -50" is Minus 50px from the top of the element allowing some padding at the top.