Easiest way to clear the values of all controls in a div using jquery?
3 answers
If these are only text fields (<input type = "text"> fields), then $ ("form: input"). val (""); would be the easiest way. If you have multiple types of inputs, you should check this.
http://www.learningjquery.com/2007/08/clearing-form-data
Looks at how to create a form cleanup plugin.
+3
a source to share
$('#form input').attr('value','');
Reset radio buttons and check boxes:
$('#form input[type=radio]').attr('checked','');
It might be easier to combine this:
$('#form input').attr('value','').attr('checked','');
But if this is for all possible choices, this should work too:
$('#form').each(function() {
this.reset();
});
+6
a source to share