jQuery API 返回首页目录 | jQuery API 中英文对照版
submit(fn)
submit(fn)

在每一个匹配元素的submit事件中绑定一个处理函数。

返回值:jQuery

参数:

  • fn (Function): 在每一个匹配元素的submit事件中绑定的处理函数

示例:

如果输入框中没有输入文本,阻止表单提交。

$("#myform").submit( function() {
 return $("input",   this).val().length > 0; 
} ); 

HTML 代码:

<form id="myform"><input /></form>

 
submit(fn)

Bind a function to the submit event of each matched element.

Return value: jQuery
Parameters:

  • fn (Function): A function to bind to the submit event on each of the matched elements.

Example:

Prevents the form submission when the input has no value entered.

 $("#myform").submit( function() {
     return $("input", this).val().length > 0;   
 } );  
Before:
 <form id="myform"><input /></form>  


相关链接
asp之家 | jQuery官方网站 | jQuery中文网 | 电子书作者网站 | 电子书作者blog