我有一個div,如果scrollTop值超過了122px就會淡入。jquery scrollTop event on mobile not working
這可以在桌面上正常工作(瀏覽器窗口縮小到低於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(函數(){'這個塊也記錄準備使用其中之一。 – Jai
這應該運行良好:[https://jsfiddle.net/hnyaq2hk/2/](https://jsfiddle.net/hnyaq2hk/2/) – morels