form表单重置

表单提交后。需要清空数据的几种方法

1、第一种情况

jQuery没有reset()方法,调用Java的reset()方法

$('.reset').click(function () {
   $('#myform')[0].reset();
});

 

2、第二种情况 (排除法)

$('.reset').click(function () {
$(':input', '#myform')
 .not(':button, :submit, :reset, :hidden,:radio') 
 .val('')
 .removeAttr('checked')
 .removeAttr('selected');

});

 

3、第三种情况(循环找到值)

$('.reset').click(function () {
$('.search_form').find(':text,select').each(function () {
$(this).val('');
});
$('input:checkbox').removeAttr('checked');
});

 

posted @ 2018-10-25 16:28  小令君  阅读(4045)  评论(0编辑  收藏  举报