How can i stop propagation for link?
<script src="http://code.jquery.com/jquery.min.js"></script>
<script>
$(function() {
$("#g").click(function(event){
alert("Link clicked");
event.stopPropagation();
});
});
</script>
<a id="g" href="http://google.com">Google</a>
I want the browser don't go to google, just show alert.
You have to use event.preventDefault();
to prevent the default action -navigating to Google- from happening.
You will need event.preventDefault()
and also return false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With