jQuery设置菜单栏置顶

$().ready(function(){
			
			$(window).scroll(function(){
				if (document.body.scrollTop > 650) {
					$("nav").css("position","fixed").css("top",0);
				} else {
					$("nav").css("position","absolute").css("top","660px");
				}
				
			});
		});

  

为$(window)窗口对象绑定滚动事件,

document.body.scrollTop可得到视口滚动的高度
posted @ 2015-03-27 14:58  j2go  阅读(278)  评论(0)    收藏  举报