Skip to content

jQuery: Prevent Href/Hyperlink

This snippet will prevent the default behaviour of a hyperlink

<a href=”#”>Go </a>

<script>
$(document).ready(function(){
$(‘#do-nothing’).click(function(e) {
e.preventDefault();
});
});
</script>

Share

Be First to Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.