jQuery .on(“click”)总是在href触发之前运行吗?

$("a").on("click",function (e) {
    doSomething();
});
...
<a href="http://website.com">My Link</a>

将doSomething()总是在“href”之前运行,在每个浏览器中?

解决方法

是的,你的处理程序将始终运行.例如,如果需要,您可以取消认行为(导航到href url)
$("a").on("click",function (e) {
   e.preventDefault(); // --> if this handle didn't run first,this wouldn't work
   doSomething();
});

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: &lt;span id=&quot...
jQuery 添加水印 &lt;script src=&quot;../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...