【发布时间】:2016-01-17 19:18:06
【问题描述】:
如果 scrollTop 值超过 122px,我有一个淡入的 div。
这在桌面上运行良好(浏览器窗口缩小到 500 像素以下以模拟移动屏幕尺寸)但在移动设备上不起作用。有解决办法吗?
我的 HTML:
<div id="topNav" class="fw">
<div class="container">
<div id="scrollLogo">
<img src="images/dualLogoMob-scroll.png" width="63" height="30" alt=""/>
</div><!-- /#scrollLogo-->
<div class="twelve columns">
<a href="#" onClick="return false;" id="mobMenuTrig" class="test">Menu</a>
</div><!-- /.twelve.columns-->
</div><!-- /.container-->
</div><!-- /#topNav-->
工作网址:http://www.altitude-digital.co.uk/dev/DUAL-SITE/index.php
我现在的 JS:
<script>
jQuery(document).ready(function(){
jQuery("#scrollLogo").hide();
jQuery(function () {
jQuery(window).scroll(function () {
if (jQuery(window).scrollTop() > 122) {
jQuery('#scrollLogo').fadeIn();
} else {
jQuery('#scrollLogo').fadeOut();
}
});
});
});
</script>
【问题讨论】:
-
jQuery(function () {这个块也是文件准备使用其中之一。 -
这应该可以正常工作:https://jsfiddle.net/hnyaq2hk/2/
标签: jquery jquery-mobile scrolltop