How to .reset() form with jQuery

Such jQuery call won’t work:

1
2
	$('#formId').reset();
	// error: $("#formId").reset() is not a function

As the tutorial shows (yes, I never read manuals before I get into troubles as well, but always google answers before think, lol), we can have the following:

1
2
3
4
5
function resetForm(id) {
	$('#'+id).each(function(){
	        this.reset();
	});
}

…and somewhere on a page this:

1
	<input type="button" onclick="resetForm('formId');" />

 

From: http://simple.procoding.net/2008/11/22/how-to-reset-form-with-jquery/

posted @ 2012-05-07 18:45  Lux.Y  阅读(224)  评论(0)    收藏  举报