[英]scrollTop doesn't work on jQuery popup box
This is my script for scrolling. 这是我的滚动脚本。
$("#oneA").click(function() {
$('html, body').animate({
scrollTop: $("#twoA").offset().top
}, 2000);
});
and my html 和我的HTML
<div id='oneA' style='height:100px;'></div>
<div id='twoA' style='height:100px;margin-top:300px'></div>
The above works fine as I tested on a static/normal page. 当我在静态/普通页面上进行测试时,以上方法工作正常。 But when I try the same on a popup box, it doesn't work at all. 但是,当我在弹出框上尝试相同操作时,它根本不起作用。 I suspect this could be library conflict between the popup and the jQuery scrolling. 我怀疑这可能是弹出窗口和jQuery滚动之间的库冲突。
I've placed these libraries 我已经放置了这些库
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src='../js/jquery.magnific-popup.min.js'></script>
<script src="../js/index.js"></script>
in the footer for the popup box. 在弹出框的页脚中。 Without this the popup won't appear.What's the possible way to make the scrollTop work on this popup, please? 否则,弹出窗口将不会显示。请问如何使scrollTop在此弹出窗口上工作?
$("#oneA").click(function() {
$('#popupId').animate({
scrollTop: $("#twoA").offset().top
}, 2000);
});
In the place of, html,body
I replaced with the popupbox id and it worked within popup. 我用popupbox id代替了html,body
,它在弹出窗口中起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.