jQuery .submit()
.submit()
.submit( handler )Returns: jQuery
Description: Bind an event handler to the "submit" JavaScript event, or trigger that event on an element.
version added: 1.0.submit( handler )
- handlerA function to execute each time the event is triggered.
version added: 1.4.3.submit( [eventData ], handler )
- eventDataType: AnythingAn object containing data that will be passed to the event handler.
- handlerA function to execute each time the event is triggered.
version added: 1.0.submit()
- This signature does not accept any arguments.
This method is a shortcut for .on( "submit", handler )
in the first variation, and .trigger( "submit" )
in the third.
The submit
event is sent to an element when the user is attempting to submit a form.
It can only be attached to <form>
elements. Forms can be submitted either by clicking an explicit <input type="submit">
, <input type="image">
, or <button type="submit">
, or by pressing Enter when certain form elements have focus.
Depending on the browser, the Enter key may only cause a form submission if the form has exactly one text field, or only when there is a submit button present. The interface should not rely on a particular behavior for this key unless the issue is forced by observing the keypress event for presses of the Enter key.
For example, consider the HTML:
<form id="target" action="destination.html">
<input type="text" value="Hello there">
<input type="submit" value="Go">
</form>
<div id="other">
Trigger the handler
</div>
The event handler can be bound to the form:
$( "#target" ).submit(function( event ) {
alert( "Handler for .submit() called." );
event.preventDefault();
});
Now when the form is submitted, the message is alerted. This happens prior to the actual submission, so we can cancel the submit action by calling .preventDefault()
on the event object or by returning false
from our handler. We can trigger the event manually when another element is clicked:
$( "#other" ).click(function() {
$( "#target" ).submit();
});
After this code executes, clicks on Trigger the handler will also display the message. In addition, the default submit
action on the form will be fired, so the form will be submitted.
The JavaScript submit
event does not bubble in Internet Explorer.
However, scripts that rely on event delegation with the submit
event will work consistently across browsers as of jQuery 1.4, which has normalized the event's behavior.
Additional Notes:
- As the
.submit()
method is just a shorthand for.on( "submit", handler )
, detaching is possible using.off( "submit" )
. - Forms and their child elements should not use input names or ids that conflict with properties of a form, such as
submit
,length
, ormethod
. Name conflicts can cause confusing failures. For a complete list of rules and to check your markup for these problems, see DOMLint.
jQuery .submit()的更多相关文章
- jquery submit选择器 语法
jquery submit选择器 语法 作用::submit 选择器选取类型为 submit 的 <button> 和 <input> 元素.如果 <button> ...
- jquery submit事件
jquery submit 事件 $('#form').submit(function(){ if(true){ //do return true; }else{ //do return false; ...
- jquery submit()不能提交表单的解决方法
<form id="form" method="get"> <input type="text" name="q ...
- jquery submit ie6下失效的原因分析及解决方法
ie6中, $('a.btn').click(function(){ form.submit(); }) 点击失效: 分析: 微软低版本浏览器会先执行link标签的自身事件也就是href事件,这样就中 ...
- jquery submit() 提交失败
今天写一个表单提交 居然走到$('#wechat_form').submit() 这,但怎么都没有提交这个表单 google 了一下 Additional Notes:Forms and their ...
- jquery submit()不执行
好吧我承认我竟然犯低级错误了...我忏悔...为了提醒自己置顶一个礼拜 <form id="form" method="post"> <inp ...
- jquery 之选择器
一.基本: HTML代码: <p class="p1">p段落</p> <h class="h1">h标签</h> ...
- Web开发——jQuery基础
参考: 参考W3School:jQuery 教程 参考:jQuery 参考手册 参考(常用):jQuery API 测试 JavaScript 框架库 - jQuery 测试 JavaScript 框 ...
- jQuery常用事件方法详解
目录 jQuery事件 ready(fn)|$(function(){}) jQuery.on() jQuery.click jQuery.data() jQuery.submit() jQuery事 ...
随机推荐
- U盘重装系统
一.准备工作 (1)8G以上空间的U盘一个: (2)将U盘制作好启动工具: 1.下载启动工具制作软件(常用的有:大白菜.电脑店.老毛桃.快启动等等一系列软件,直接百度这些软件的名称,或者百度U盘启动制 ...
- SQL数据库字段数据类型详细说明
这里先总结数据类型.MySQL中的数据类型大的方面来分,可以分为:日期和时间.数值,以及字符串.下面就分开来进行总结. 日期和时间数据类型 MySQL数据类型 含义 date 3字节,日期,格式:20 ...
- node-images Windows 64-bit with Unsupported runtime 错误解决办法 及 node 历史版本下载
在做项目的时候下载的最新的10.16[2019.6.12]版本,出现了模块不兼容的问题[node-images]. 在git上发现了相同问题 https://github.com/zhangyuanw ...
- 07 Deque的应用案例-回文检查
- 回文检测:设计程序,检测一个字符串是否为回文. - 回文:回文是一个字符串,读取首尾相同的字符,例如,radar toot madam. - 分析:该问题的解决方案将使用 deque 来存储字符串 ...
- python time,calendar,datetime
time sleep:休眠指定的秒数(可以是小数) localtime:将一个时间戳转换为time.struct_time类型的对象(类似于元组) # 将一个时间戳转换为一个类似于元组的对象,不指定时 ...
- N4语法
第一期 授受关系 这里讲的授受关系是指“物的收受”也就是前后两个主体之前的“物的收受”. 请看以下三个基本句型:(从接收者B来分析) 1. AはBに-を あげる(平辈.晚辈) (A给 ...
- openstack mitaka开启三层网络vxlan
在这之前,先把之前基于flat模式创建的虚机,全部删除 控制节点: 配置 修改/etc/neutron/neutron.conf的[DEFAULT]区域 将 core_plugin = ml2 ser ...
- deep_learning_Function_numpy_newaxis参数
np.newaxis的作用就是在这一位置增加一个一维,这一位置指的是np.newaxis所在的位置,比较抽象,需要配合例子理解. x1 = np.array([1, 2, 3, 4, 5]) # th ...
- DP问题练习1:数字三角最短路径问题
DP问题练习1:数字三角最短路径问题 问题描述 给定一个数字三角形,找到从顶部到底部的最小路径和.每一步可以移动到下面一行的相邻数字上. 样例: 比如,给出下列数字三角形: 2 3 4 6 5 7 4 ...
- win7安装xmanager报错error1303、err1317
安装xmanager时出现的一些问题,记录如下. 1.安装xmanager时,提示error1303.如下图,按照百度的办法,创建相应的文件夹后,点击重试. 2.重试后提示err1317,如下图所示. ...