form表单重置

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');
});