0

I have a page (Bootstrap 3) that opens a modal. There are groups of Collapse panels (accordions) on the modal. I would like to have the page scrollTop when the collapse headers are clicked open. Javascript that has been tried (using ScrollTo plugin for this sample):

$('.panel').on('shown.bs.collapse', function () {
   var panel = $(this).find('.in');
   var mtop = $(this).closest('.modal.in');
   $.scrollTo(mtop.offset().top-25, 350);
}); 

The window behind the modal will scrollTop. Through the console I can get the modal to scrollTop a certain number of pixels. Just can't seem to figure out how to target the collapse that is opened. Any help/ideas appreciated.

3
  • Please relook at this line: $.scrollTo(mtop.offset().top-25, 350); May 1, 2015 at 21:12
  • Create a Jsfiddle if possible also, buddy. May 1, 2015 at 21:12
  • OK, I've made a simplified fiddle for this. I changed the javascript a bit, but tries to accomplish the same thing generally. jsfiddle.net/jhottle/2z4ncp4u May 1, 2015 at 21:39

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.