转到单击事件jquery上的锚点链接 [英] Go to anchor link on click event jquery

查看:704
本文介绍了转到单击事件jquery上的锚点链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如描述所说,我发现了许多关于平滑滚动和java脚本上的位置属性的东西,但似乎什么也没做我想找的只是模仿htmla标签的功能(我需要不要为此项目使用html链接标记)

As the descriptions says, I've found many things about smooth scrolling and the location property on java script but nothing seems to do what Im looking for which is simply imitate the function of a html "a" tag (I need to NOT use the html link tag for this project)

推荐答案

使JQuery将用户带到与页面不同的URL(如锚标记)将window.location附加到事件。

To make JQuery take the user to a different URL than the page (like an anchor tag) attach window.location to the event.

例如,这个:

$('#ClickMe').click(function(){ window.location = 'index.php'; });

如果用户点击具有IDClickMe的元素,会将用户带到index.php (EG ......

Would take the user to index.php if he clicks on the element that has the ID "ClickMe" (E.G. ...

这篇关于转到单击事件jquery上的锚点链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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