JQuery点击某个元素跳转到当前页面的目标元素位置
先引入jquery库,然后在添加下面的代码
$(".tsms").click(function (){
$("html,body").animate({scrollTop: $(".bold_tsms").offset().top}, 500);
});
//其中$(".tsms")是被点击元素,$(".bold_tsms")是所要到达位置的元素
先引入jquery库,然后在添加下面的代码
$(".tsms").click(function (){
$("html,body").animate({scrollTop: $(".bold_tsms").offset().top}, 500);
});
//其中$(".tsms")是被点击元素,$(".bold_tsms")是所要到达位置的元素