jQuery in Action
The Form Plugin
275
Note that this familiar form has been initialized with values via its
HTML
markup.
The text field and text area have been initialized via their
value
attributes, the
dropdown has had one of its options
selected
, and one check box and one radio
button have been
checked
.
Click the Clear Form button, and watch what happens. The text field and text
area are cleared, the dropdown has no selection, and all check boxes and radio
buttons are unchecked.
buttons are unchecked.
Now click the Reset Form button, and note how the controls all revert to their
original values. Change the values of each control, and click Reset Form, noting
how, once again, the original values are restored.
how, once again, the original values are restored.
The syntaxes for these commands are as follow:
Command syntax: clearForm
clearForm()
Clears the value of any controls in the wrapped set or that are descendants of elements in
the wrapped set
the wrapped set
Parameters
none
Returns
The wrapped set
The wrapped set
Figure 9.2 The Clear and Reset Laboratory shows us the difference between a reset and a clear.