Reputation: 6266
How can i execute a function before I click on anchor tag <a href="/foo" id="foo">Foo</a>
and after click on it ?
I try this :
$(document).on('click', '#foo', function(e) {
// stuff to do
return false;
}
The function is executed but the link /foo is not loading like the default behavior.
Upvotes: 2
Views: 2203
Reputation: 167240
Well, I don't understand why people shout at you, being clearer, your question can be answered this way:
$(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;
}
Upvotes: 6