jquery清空表单数据示例分享
2014-02-13 00:00
609 查看
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清空表单数据
- jquery清空表单数据
- jquery选择符快速提取web表单数据示例
- jquery提交form表单简单示例分享
- AJAX提交表单后要清空,否则再次提交原来的数据会认为重复提交,提交失败。使用ajaxSubmit 函数需要引入jquery.form.min.js 文件
- jquery提交form表单简单示例分享
- 【jQuery示例】遍历表单数据并显示
- jquery选择符快速提取web表单数据示例
- 浅谈jQuery的offset()方法及示例分享
- Jquery表单提交JSON数据
- jquery清空form表单
- jQuery 动态操作表单数据
- 分享一个快速将传统表单转化为AJAX支持的表单的jQuery插件 - ALAJAX
- c#版json数据解析示例分享
- jquery+asp.net操作json数据的示例
- JQuery获取或设置ckeditor的数据(示例代码)
- jQuery Easyui datagrid/treegrid 清空数据
- jquery动态添加删除一行数据示例
- 分享27款非常棒的jQuery 表单插件