I have a navigation in the top right corner that will scroll down a page with a user. I am using this jQuery code:
开发者_Go百科var $scrollingDiv = $("#scrollingDiv");
$(window).scroll(function(){
$scrollingDiv
.stop()
.animate({"marginTop": ($(window).scrollTop() + 30) + "px"}, "fast" );
});
the CSS:
#scrollingDiv{background-color:#fff;margin-left:4%;margin-top:10px;padding:0 2% 2%;}
It works great, the Problem is: The navigation filters the content, so you can be at the bottom of the page, click on a link in the navigation and it will filter the content so there will only be 2 paragraphs instead of 20. The scrolling navigation will get STUCK on the bottom in IE. Other browsers it moves back to the top.
I tried using a
<a name="top"> </a>
But that didnt work. Any suggestions?
here is what you do:
$("a.nav").click(function () {
$("#scrollingDiv").css({marginTop: '10px'});
});
This will reset the marginTop so it won't get stuck on the bottom
精彩评论