源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

jquery清空表单数据示例分享

  • 时间:2021-01-06 11:21 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:jquery清空表单数据示例分享
[u]复制代码[/u] 代码如下:
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;   }); };
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部