如何使用jQuery滚动到div的顶部? [英] How to scroll to top of a div using jQuery?

查看:543
本文介绍了如何使用jQuery滚动到div的顶部?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个div里有一个gridview ..我想从div底部使用jquery滚动到div的顶部..任何建议..

I have a gridview inside a div.. I want to scroll to top of the div from the bottom of the div using jquery.. Any suggestion..

<div id="GridDiv">
// gridview inside..
</div>

我的gridview会自定义分页生成链接按钮...我会滚动到顶部点击链接按钮底部的点击...

My gridview will have custom pagination generated link buttons in it... I will scroll to top of the div from the bottom of the link button click ...

protected void Nav_OnClick(object sender, CommandEventArgs e)
    {
        LinkButton lb1 = (LinkButton)sender;
        //string s = lb1.ID;
        ScriptManager.RegisterClientScriptBlock(lb1, typeof(LinkButton), 
 "scroll", "javascript:document.getElementById('GridDiv').scrollTop = 0;", true);

代替javascript,我会调用jquery函数...任何建议...

In the place of javascript, I ll call the jquery function... Any suggestion...

编辑:

完全像每个用户页面的Stackoverflow问题...更改页面nos它滚动到顶部与流畅的效果...我想实现... ...

Exactly like Stackoverflow questions per user page... When changing page nos it scrolls to top with smooth effect... I want to achieve that...

推荐答案

您可以使用:

You could just use:

<div id="GridDiv">
// gridview inside...
</div>

<a href="#GridDiv">Scroll to top</a>

这篇关于如何使用jQuery滚动到div的顶部?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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