admin管理员组文章数量:1332395
Does anyone know how to detect the clicked href URL in JQuery? For example I have the following links, some is redirect to the new page and some will call to the javascript to expand the div. How can I use the JQuery/Javascript to detect the href if no ID been use.
<a href="www.test">Test 1</a>
<a href="javascript:test()">Test 2</a>
<a href="www.test2">Test 3</a>
<a href="www.test3">Test 4</a>
<a href="javascript:test2()">Test 5</a>
Does anyone know how to detect the clicked href URL in JQuery? For example I have the following links, some is redirect to the new page and some will call to the javascript to expand the div. How can I use the JQuery/Javascript to detect the href if no ID been use.
<a href="www.test.">Test 1</a>
<a href="javascript:test()">Test 2</a>
<a href="www.test2.">Test 3</a>
<a href="www.test3.">Test 4</a>
<a href="javascript:test2()">Test 5</a>
Share
Improve this question
edited Sep 17, 2012 at 23:57
Jin Yong
asked Sep 17, 2012 at 23:02
Jin YongJin Yong
43.8k72 gold badges144 silver badges194 bronze badges
2
- 4 What do you mean by detect the href? – Ram Commented Sep 17, 2012 at 23:04
- 1 I am confused about the 'selected' word. Are you talking about when someone is using the tab key to move through the tabable objects? Or, are you asking to detect which one has been clicked? – demersus Commented Sep 17, 2012 at 23:06
1 Answer
Reset to default 7Does anyone know how to detect the clicked href URL in JQuery?
$("a").click(function(event){
// Capture the href from the selected link...
var link = this.href;
alert(link);
// do something if required....
// would prevent the link from executing, if that is something you want to do...
return false; // not needed if you want the link to execute normally...
});
本文标签: How to detect the clicked href URL in JQueryJavascriptStack Overflow
版权声明:本文标题:How to detect the clicked href URL in JQueryJavascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742284091a2446619.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论