Life is a Short Span, try to earn knowledge in every Field.
Tuesday, 23 April 2013
Blank out a form/ reset a form with jQuery
First method:
<form id="form">
<input type="text" value="Here is some data" id="data" />
<input type="button" value="Clear Input" id="button" />
</form>
$(function(){
$('#button').click(function(){
$(':input','#form').not(':button, :submit, :reset, :hidden').val('').removeAttr('checked,selected');
});
});
Second method:
function clearForms()
{
var i;
for (i = 0; (i < document.forms.length); i++) {
document.forms[i].reset();
}
}
Happy Coding!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment