Does jQuery .on("click") always run before <a> href fires?

jquery

Solution

Yes, your handler will run always first. That's what allows you, for instance, to cancel default behavior (navigate to href url) if necessary

$("a").on("click", function (e) {
   e.preventDefault(); // --> if this handle didn't run first, this wouldn't work
   doSomething();
});

Problem

``` $("a").on("click", function (e) { doSomething(); }); ... <a href="http://website.com">My Link</a> ``` Will `doSomething()` always run before the "href", in every browser?

Original source