Stop jQuery from scrolling when element changes out of the view
I have a very long page. At the top I have a banner div with a background-image that changes every 10 seconds through a timer.
When you scroll down to see the content "below the fold", jQuery then scrolls to the top to show the new banner image.
This is very disruptive -how could I stop jQuery from scrolling to the top? Thank you.
timer = setTimeout(function() {
$('div#banner'开发者_运维问答).css('background-image', 'url(...)'; }
// set timeOut again.
, 10000);
FYI -As the comments points out, the issue was not caused by the "css" function but by a "fadeOut" "fadeIn" effect. Hope this helps somebody else. Thank you.
精彩评论