jquery 表单 清空
来源:互联网 发布:java 双引号转义 编辑:程序博客网 时间:2024/05/16 13:00
做了个复杂查询的页面,字段太多了,填了一次,想清空挺麻烦的
虽然reset方法可以做到一部分,但是如果你有个元素是这样的
那么点击reset只会还原成50
于是乎,有了以下方法,网上浏览过来,
It is using the :input
selector which will match all input, textarea, select and button elements. Since we are passing #myform
as the second argument, it will only find inputs inside this form
element. Then it filters out all buttons, submits, resets and hidden
inputs using not()
. Then it is using val()
to set the value of the remaining fields to an empty string, and then it uses removeAttr
to remove the checked
and selected
attribute of the fields in case you have any radio/checkbox/select inputs. Tada.
很强大,包括了所有的情况
- $('#myform')[0].reset();
虽然reset方法可以做到一部分,但是如果你有个元素是这样的
- <input name="percent" value="50"/>
那么点击reset只会还原成50
于是乎,有了以下方法,网上浏览过来,
- $(':input','#myform')
- .not(':button, :submit, :reset, :hidden')
- .val('')
- .removeAttr('checked')
- .removeAttr('selected');
It is using the :input
selector which will match all input, textarea, select and button elements. Since we are passing #myform
as the second argument, it will only find inputs inside this form
element. Then it filters out all buttons, submits, resets and hidden
inputs using not()
. Then it is using val()
to set the value of the remaining fields to an empty string, and then it uses removeAttr
to remove the checked
and selected
attribute of the fields in case you have any radio/checkbox/select inputs. Tada.
很强大,包括了所有的情况
0 0
- jquery 清空表单
- jquery 表单 清空
- jquery 表单 清空
- jquery 清空表单
- jquery 表单清空
- jQuery 清空表单
- jquery 表单 清空
- jquery 表单 清空
- jquery 表单 清空
- jquery 表单清空
- jquery 表单 清空
- jquery 表单 清空
- 用jquery 清空 表单
- jquery清空表单数据
- jquery清空form表单
- 表单清空方法 JQuery
- 表单清空方法 JQuery
- JQuery 表单清空 真正的重置
- Android自定义View中的常用方法(距离、位置、点击事件)
- jQuery 事件 - keyup() 方法及文本框只输入数字
- 关于LitePal使用时出现的常见问题与解决办法
- android system property
- 汇编基于PC机的8254日时钟中断的字符串动态显示——时:分:秒
- jquery 表单 清空
- cblib实现JDK动态代理的简单实例
- LESS使用实例总结
- printf打印
- “破锣摇滚”乐队
- 给Linux系统/网络管理员准备的Nmap命令的29个实用范例
- centos 查看文件大小
- 使用Bootstrap Switch插件的滑动checkbox
- JQuery获取和设置select下拉框的值