用户登录
用户注册

分享至

实现点击到底部、顶部、指定div功能

  • 作者: 嗫?暁雲?
  • 来源: 51数据库
  • 2021-08-25

顶部:

$(".back_top").click(function () {
  scrollto(0, 0);
});

function gotop() {

  $('html, body').animate({scrolltop:0}, 'slow');

}

底部:

$(".back_bottom").click(function () {
  $('html,body').animate({ scrolltop: document.documentelement.scrollheight }, 800);
});

function gobottom(){

  window.scrollto(0, document.documentelement.scrollheight-document.documentelement.clientheight);

}

指定div:

function godiv(div) {

  var a = $("#"+div).offset().top;

  $("html,body").animate({scrolltop:a}, 'slow'); 

}


 

软件
前端设计
程序设计
Java相关