为了通过
return false;
问题,请尝试处理自定义事件。
// Bind custom event to all forms
$('form').bind('custom_submit_event',function() {
alert('custom submit event');
});
// Bind submit event to all forms that triggers the custom event
$('form').submit(function() {
$(this).trigger('custom_submit_event');
});
// Your regular submit event for a specific form
$('#myform').submit(function() {
// Run validation/submission code
return false;
});
我不经常使用自定义事件,但这对我很有用。不知道为什么它不能与其他事件以及。
您还可以将处理程序分配给
document
. 只要你不打
返回false;
问题,他们的事件将泡沫文件。可能比在整个页面中有许多事件处理程序的开销更好(更有效)。
$(document).click(function() {
alert('click')
})
.keydown(function() {
alert('keydown')
});