jQuery重置表单

一、 

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

$("#form")取得id为form的jQuery对象
$("#form")[0]可以把这个jquery对象转成html对象
后面的.reset()方法不是jquery对象的方法,但是是html对象的方法。

二、

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

 

posted @ 2017-08-23 11:03  余小果  阅读(1928)  评论(0编辑  收藏  举报