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事 ...
随机推荐
- O020、理解 Glance
参考https://www.cnblogs.com/CloudMan6/p/5384923.html OpenStack 由 Glance 提供 Image 服务. 理解 Glance ...
- PostgreSQL 按照日期范围查询
method 1 select * from user_info where create_date >= '2019-05-01' and create_date < '2019-08- ...
- TensorFlow入门——MNIST深入
#load MNIST data import tensorflow.examples.tutorials.mnist.input_data as input_data mnist = input_d ...
- GO语言语法入门
引言 Go Go语言是谷歌2009发布的编程语言,它是一种并发的.带垃圾回收的.快速编译的语言. 它结合了解释型语言的游刃有余,动态类型语言的开发效率,以及静态类型的安全性.它也打算成为现代的,支持网 ...
- IDEA打开光标是粗黑色,backspace键、insert键点击无效的解决办法
问题描述:打开IDEA的编译器之后,界面显示的光标变粗,点击backspace键和insert键盘之后无效 解决方法:打开File——Settings——Plugins,在右侧的搜索栏中搜索IdeaV ...
- navicat for mysql 12 的破解安装和基本操作
需要安装Navicat软件 可以复制百度云链接,若失效,请联系我,我会尽快回复 将链接中的破解文件复制到软件安装的位置即完成破解 链接:https://pan.baidu.com/s/1sIkjsd3 ...
- json文件处理四个函数
import json # json.dumps(json_dict,ensure_asscii = False)函数的使用,将字典转化为字符串 ensure_ascii=False将Unicode编 ...
- IO模型(epoll)--详解-03
写在前面 epoll是开发linux高性能服务器的必备技术至,epoll本质,是服务端程序员的必须掌握的知识. 七.epoll的原理和流程 本节会以示例和图表来讲解epoll的原理和流程. 创建epo ...
- 初学者如何从零学习人工智能?(AI)
一.机器学习 有关机器学习领域的最佳介绍,请观看Coursera的Andrew Ng机器学习课程. 它解释了基本概念,并让你很好地理解最重要的算法. 有关ML算法的简要概述,查看这个TutsPlus课 ...
- 封装ORM.py与mysql_client.py代码
ORM.py ''' ORM: 对象关系映射 ---> 映射到数据库MySQL中的数据表 类名 ---> 表名 对象 ---> 一条记录 对象.属性 ---> 字段 模拟Dja ...