onClick使用jQuery .animate转到页面底部 [英] onClick go to the bottom of page using jQuery .animate

查看:52
本文介绍了onClick使用jQuery .animate转到页面底部的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个表,其中最后一列包含操作按钮,用于打开表下的另一部分。打开该部分时,正文页面保留在按下操作列按钮的位置。我需要使用jQuery,优选使用.animate,将.html页面滚动到表格下方的打开部分。

I have a table where last column contains action buttons which opens another section under the table. When that section is opened the body page remain where the button from action column was pressed. I need to use a jQuery preferably with .animate which scrolls .html page to that opened section under the table.

小提琴示例: http://jsfiddle.net/Ksb2W/110/

如果有人帮忙我这个。
谢谢。

If anyone cand help me with this. Thank you.

推荐答案

演示 http://jsfiddle.net/h4ZQR/ http:// jsfiddle.net/byRRY/

良好的API: http:/ /api.jquery.com/scrollTop/

请注意:您可以使用: .animate({scrollTop:$( #whateverdiv)。offset()。top}); 转到页面的某些部分。

Please note: you can use: .animate({scrollTop: $("#whateverdiv").offset().top}); to go to certain sections of page.

希望这会有所帮助

html

<a href="#bottom" id="hulk">Click me to go to bottom</a>

代码

$("#hulk").click(function() {
  $("html, body").animate({ scrollTop: $(document).height() }, "slow");

});​

OR

$("a[href='#bottom']").click(function() {
  $("html, body").animate({ scrollTop: $(document).height() }, "slow");
  return false;
});​

这篇关于onClick使用jQuery .animate转到页面底部的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆