![](/img/trans.png)
[英]How to execute href link and after that onClick function in Anchor tag <a>
[英]Execute function before anchor tag and load it after
在单击锚标记<a href="/foo" id="foo">Foo</a>
和单击后如何执行函数?
我尝试这样:
$(document).on('click', '#foo', function(e) {
// stuff to do
return false;
}
该函数已执行,但是/ foo链接没有像默认行为那样加载。
好吧,我不明白为什么人们会对你大喊大叫,更清楚地说,你的问题可以这样回答:
$(document).on('click', '#foo', function(e) {
// stuff to do
alert("Hello");
// finally follow the link
location.href = $(this).attr("href");
// Or may be giving `return true;` could work?
return false;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.