How to prevent link click default action or form submission (jQuery)
If you want to change link click default behavior, you could use jQuery for this purpose.
Let's assume we have a link:
<a href="/link" id="example-link">Link</a>
jQuery code, which will prevent link click default action:
$('#example-link').click(function(e) {
e.preventDefault();
//your code
});
The key thing here is the e parameter, which is passed to the function and the e.preventDefault()
Comments