代码如下:

//随鼠标上下滚动 
$(window).bind('scroll resize',function(){ 
$('#sidebar').stop(true, true).animate({ 
'top': $(document).scrollTop() + 'px' 
},500); 
}).scroll().resize();