.formReset()
Categories: Attributes, Tree Traversal | Forms
.formReset()Returns: jQuery
Plugin: jQuery.fn.form
Description: Resest each inputs and first form element of matched elements.
-
.formReset()
version added: 1.0
This method provides to reset one or more inputs, or a complete form.
The .formReset()
reset each input, select and textarea and the complete first matched form.
-
Reset form elements.
HTML:
<div> <form id="form_1"> <input type="radio" name="A" value="1"/> <input type="radio" name="A" value="2"/> <input type="checkbox" name="B" value="1"/> <input type="checkbox" name="B" value="2"/> <input type="text" name="C"/> <textarea type="text" name="D"></textarea> </form> <form id="form_2"> <input type="radio" name="A" value="2"/> <input type="radio" name="A" value="3"/> <input type="checkbox" name="B" value="2"/> <input type="checkbox" name="B" value="3"/> </form> </div>
Code:
$(':checkbox').formReset(); // reset all input type checkbox $('#form_2,textarea').formReset(); // reset all inputs form_2 and the textarea of form_1