How to scroll to an element within a modal using jquery?

若如初见. 提交于 2019-12-04 01:14:09

It looks like you are calling the animate method on html and body.

$('html, body').animate(...);

If you want to scroll the modals window you have to call the animate method on that element instead.

$('#modal').animate(...);

Where #modal is the element containing the elements you've created.

edit:

I see that you tried to call animate on the modal. Here is a fiddle that scrolls elements in a modal when you click the button.

also in the code you have a closing bracket after #Element which is causing the script to error: ...scrollTop: $('#Element'])...

If you want to see the contents that are getting hidden you can add a CSS style to the DIV to handle the overflow. This will automatically create a vertical scroll bar for you once the content exceeds the view area of DIV.

$("#someDivID").css("overflow","auto");

All of the properties can be referenced at the URL below.

http://www.w3schools.com/cssref/pr_pos_overflow.asp

Hope that helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!