[英]How can I use Simple Modal to scroll to the top of my page just before the modal launches?
I'm successfully using Simple Modal to launch a modal when a button is clicked, however, I want the page to scroll to the top first. 单击按钮时,我已成功使用“简单模态”启动模态,但是,我希望页面首先滚动到顶部。 I tried placing an anchor tag at the top of the page and referencing it in my link using , but it didn't work. 我尝试将锚标记放置在页面顶部,并使用引用我的链接,但这没有用。 The Simple Modal still worked, but it didn't scroll to the top of the page first. Simple Modal仍然有效,但没有先滚动到页面顶部。 Is there a way to edit the simple modal javascript to make it first scroll to the top of the page before the modal is opened? 有没有一种方法可以编辑简单的模式JavaScript,使其在模式打开之前先滚动到页面顶部?
Use a callback: http://www.ericmmartin.com/projects/simplemodal/#options 使用回调: http : //www.ericmmartin.com/projects/simplemodal/#options
$('#modalContent').modal({
onOpen: function () {
$('html, body').scrollTo(0, 0);
}
});
在调用模态之前使用JavaScript: window.scrollTo(0,0)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.