I need to trigger the click event on a link and then, if none of the listeners prevented the default, change the location.
This is what I\'ve got so far:
If I understand your question correctly, you have an a
element that you don't control, which has an onclick
attribute that returns false
. Returning false
from an onclick handler prevents a click on the link from taking you to the linked page. And you don't want that.
You could store the onclick
handler function and then remove it from the link element:
var $a = $('#my_special_link');
var onclickHandler = $a.attr('onclick');
$a.removeAttr('onclick');
Then cal the stored handler function in your custom click handler:
$a.click(function() {
// ...
onclickHandler();
// ...
});