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');" /> |
Wha-ha! Just use
$(’#myFormId’)[0].reset();
“$(’#myFormId’)[0].reset();”
Thanks Konstantin, easy solution
this doesnt work..
someone please help…
add this at the end of the form
and try this,
$(’#rst_form’).click()
add this at the end of the form
<div style=”display=’none’” ><input type=”reset” id=”rst_form”></div>
and try this,
$(’#rst_form’).click()
Thanks…
easy solution but it work!!!
only this:
$(’form’)[0].reset();
get the form element…. and not the specific form directly: (’#myform’)
it work => $(’#myform’)[0].reset()
Thanks for the idea
Thanks a lot for a good idea.
well, it would better is everybody use all-around jQuery style, what means that correct solution is
$(’#myform’).get(0).reset();