jquery清空表单数据示例分享
2018-10-12 14:02
627 查看
function clearForm(form) {
// iterate over all of the inputs for the form
// element that was passed in
$(':input', form).each(function() {
var type = this.type;
var tag = this.tagName.toLowerCase(); // normalize case
// it's ok to reset the value attr of text inputs,
// password inputs, and textareas
if (type == 'text' || type == 'password' || tag == 'textarea')
this.value = "";
// checkboxes and radios need to have their checked state cleared
// but should *not* have their 'value' changed
else if (type == 'checkbox' || type == 'radio')
this.checked = false;
// select elements need to have their 'selectedIndex' property set to -1
// (this works for both single and multiple select elements)
else if (tag == 'select')
this.selectedIndex = -1;
});
};
您可能感兴趣的文章:
相关文章推荐
- jquery清空表单数据示例分享
- jquery选择符快速提取web表单数据示例
- AJAX提交表单后要清空,否则再次提交原来的数据会认为重复提交,提交失败。使用ajaxSubmit 函数需要引入jquery.form.min.js 文件
- jquery清空表单数据
- jquery提交form表单简单示例分享
- jquery选择符快速提取web表单数据示例
- 【jQuery示例】遍历表单数据并显示
- jquery清空表单数据
- jquery提交form表单简单示例分享
- jQuery 序列化表单数据 serialize() serializeArray()
- JQuery UI datepicker在选择startDate与endDate时手动清空数据后,时间选择依然有限制问题!
- Java中,当表单含有文件上传时,提交数据的如何读取(感谢作者分享)
- sql清空表数据后重新添加数据存储过程的示例
- [JAVAWEB]4.用jQuery完成数据验证和表单提交
- jQuery 序列化表单数据 serialize() serializeArray()
- jquery+asp.net操作json数据的示例
- 【分享】水晶报表在清单数据上实现前三名图表及组及深化功能示例(图文版)
- Js和Jquery中小数据点保留2位或几位的函数!(示例)
- jQuery通过ajax获得后台json数据给form表单赋值