javascript - How to scroll to an element within a modal using jquery? -
i have opened modal insert elements line line. each line has it's own id tag. the list grows bigger modal window text gets hidden @ bottom of modal window. can manually use scroll bar text scroll in modal window printed.
i have played around following code scrolls webpage behind modal. have tried replacing 'html, body' modal elements no avail.
$('html, body').animate({ scrolltop: $('#element').offset().top }, 500);
i'm sure close. suggestions?
thanks
it looks calling animate method on html , body.
$('html, body').animate(...);
if want scroll modals window have call animate method on element instead.
$('#modal').animate(...);
where #modal
element containing elements you've created.
edit:
i see tried call animate on modal. here fiddle scrolls elements in modal when click button.
also in code have closing bracket after #element
causing script error: ...scrolltop: $('#element'])...
Comments
Post a Comment