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.