Javascript: How to hijack input type=submit on click behavior?
Target the form instead, not the submit button
$("form").submit(function(e) {
e.preventDefault();
e.returnValue = false;
// do things
});
Just for the sake of keeping this answer updated change :
$("form").live('submit', function(e) {
e.preventDefault();
e.returnValue = false;
// do things
});
with :
$("form").on('submit', function(e) {
e.preventDefault();
e.returnValue = false;
// do things
});
$(selector).live()
was deprecated in Jquery 1.7 and removed from the framework in Jquery 1.9.
Here´s the documentation