<script>
$(function(){
$('.logger').bind('click',function(){
alert('we will log that the user shared something');
return true; //keep going, pretend nothing happened.
});
$('.share').bind('click',function(){
window.open('blah');
return false;
});
});
</script>
<a href="#" class="share logger">Share this</a>
I want to be able to trigger BOTH the logger and the share functions. But right now, only the share function is triggered. If I comment share function, then the logger function works fine.
I’ve also tried to change the “class” so that logger is before share.
When you
return false;in an event handler that stops the event propagation, that is why the other handler is not triggered. If you just want to stop the default action, useevent.preventDefault().This article does a good job explaining the concept: