您现在的位置:首页 >> 前端 >> 内容

实现定位锚点返回相应位置的两种方式

时间:2017/11/8 14:46:31 点击:

  核心提示:实现定位锚点返回相应位置的两种方式/*var target_top = $(#btm).offset().top;*/ //获得#btm当前顶部的垂直偏移量(便于等位到当前位置)1. //$(html...

实现定位锚点返回相应位置的两种方式

/*var target_top = $("#btm").offset().top;*/ //获得#btm当前顶部的垂直偏移量(便于等位到当前位置)

1. //$("html,body").animate({scrollTop: target_top}, 1000); //带滑动效果的跳转

2. /*$("html,body").scrollTop(target_top);*/

作者:网络 来源:Islandww的博