I have some questions with jQuery submit function.
here is work environment
jQuery: 1.7.2, chrome (18.0.1025.168 m).
There are 2 problems.
1st:
my codes like this
html
<form id="test" action="..." method="post">
<input type="text" />
<input type="submit">
</form>
jQuery
$('#test').submit(function(){
return false;
})
the problem is it works fine in firefox and opera but chrome.
2st:
html: as above.
jQuery:
$('#test').submit(function(){
if(...)
alert(something..);
return false;
})
it dosen't work in firefox,opera and chrome. it always trigger form.submit why.
I am very confused it. who can figure it out thanks!
Don't use return false;. Try this instead:
$('#test').submit(function(event){
event.preventDefault();
});
Replace:
$('#test').submit(function(){
return false;
});
with:
$('form#test').submit(function(event){
event.preventDefault();
});
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