为什么不能实现啊?
$(document).ready(function(){
$(window).scroll(function(){
var top = $(document).scrollTop();
var menu = $("#menu");
var items = $("#content").find(".item");
var currentId = "";
items.each(function(){
var m = $(this);
var itemTop = m.offSet().top;
if(top > (itemTop-200)){
currentId = "#" + m.attr("id");
}else{
return fasle;
}
});
var currentLink = menu.find(".current");
if(currentId && currentId!=currentLink.attr("href")){
currentLink.removeClass("current");
menu.find("[href="+currentId+"]").addClass("current");
}
});
});