我正在开发一个单页滚动网站和它的滚动很好。但每当我点击滚动到顶部的div,它就会把我带到最上面的位置,但当我试图向下移动网站时,它就会挂起。让我知道我在jQuery中做错了什么。
问题在Firefox下更为严重http://jsfiddle.net/swapnesh/jSa3z/
脚本 -
<script>
jQuery(document).ready(function(){
$('section[data-type="background"]').each(function(){
//assigning the object
var $bgobj = $(this);
$(window).scroll(function(){
var yPos = $(window).scrollTop() / $bgobj.data('speed');
var coords = '50%' + yPos + 'px';
//Move the background
$bgobj.css({ backgroundPosition : coords });
})
})
$(window).scroll(function(){
if( $(this).scrollTop() > 600 ) {
$('#scrollpage').fadeIn();
$('#scrollpage').click(function(){
$("html, body").animate({ scrollTop: 0 }, 600);
return false;
})
}
else {
$('#scrollpage').fadeOut();
}
})
})
</script>