如何使用jQuery使用户更深入页面? [英] How to bring user further down the page using jQuery?

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

问题描述

当用户执行某些操作时,我想将其带到页面的下方.有点像一个名字链接的工作原理.除非显然需要在不向URL添加任何其他参数或刷新页面的情况下进行此操作.

When the user performs a certain action I want to bring them further down the page. Kind of like how an a-name link works. Except obviously it needs to happen without any additional parameters being added to the url or refreshing the page.

那么jQuery的实现方式是什么?

So what would be the jQuery way of doing this:

<a href="#person">Click Me</a>

<a name='person'>Tommy</a>

编辑

一个很好的向下滑动效果也可以使用户进入页面.

a nice slide down effect to bring the user down the page would be nice too.

推荐答案

看看 ScrollTo jQuery插件.它可以满足您的需求,并支持动画.因此,您可以这样做:

Have a look at the ScrollTo plugin for jQuery. It does what you want and supports animations as well. So you could just do:

<a id="person">Tommy</a>

并使用如下插件:

$.scrollTo($('#person'));

或者,如果您不希望使用任何奇特的东西,则可以自己完成以下几行操作:

Alternatively, if you don't want any fancy stuff, you could do this by yourself in a couple of lines:

var offset = $('#person').offset();
window.scrollTo(offset.left, offset.top);

这篇关于如何使用jQuery使用户更深入页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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