所以這讓我感到非常緊張。此代碼,防止表單使用jQuery提交
$('#the_form').submit(function(e){
alert("Submit!");
return false;
e.preventDefault();
});
應該阻止我的HTML表單,
<form id="the_form">
<input type="text" name="q" />
<input type="submit" />
</form>
從刷新頁面,但事實並非如此。有沒有人有這方面的見解?
無碼return'語句後執行'包裹。 – nrodic
http://jsfiddle.net/oceog/G9JLG/1它的工作原理是,但是,沒有preventDefault()需要。 –