我有这个代码
$(window).load(function () {
$elem1 = $('#div1');
$elem2 = $('#div2');
var scrollState = 'top';
$(window).scroll(function () {
var scrollPos = $(window).scrollTop();
if ((scrollPos != 0) && (scrollState === 'top')) {
$elem1.stop().animate({
opacity: '1.0'
}, 300);
$elem2.stop().animate({
marginLeft: '50px'
}, 300);
scrollState = 'scrolled';
} else if ((scrollPos === 0) && (scrollState === 'scrolled')) {
$elem1.stop().animate({
opacity: '0.0'
}, 300);
$elem2.stop().animate({
marginLeft: '0px'
}, 300);
scrollState = 'top';
}
});
}); //]]>
当我向下滚动页面时,一旦您开始滚动,jquery 就会激活。我希望能够选择在它激活之前你走多远的页面。