- jobshow.scrollToPlace=function(elemId){
- var p=elemId||"body";
- var offset = $(p).offset(); //得到elemId这个元素层的offset,包含两个值:top和left
- $("body,html").animate({
- scrollTop:offset.top-65 //让body的scrollTop等于elemId的top,就实现了滚动(65为header悬浮的高度)
- },300);
- }
- //该片段来自于http://www.codesnippet.cn/detail/0312201514179.html
来源: http://www.codesnippet.cn/detail/0312201514179.html