Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

easiest possible way to clear values of all controls in a div using jquery?

Tags:

jquery

textbox

I have an add form inside a div which has 3-5 textboxes.. I submit the form via ajax and hide the div in the success function of it... Now i want to clear all the values of textboxes within the adddiv using jquery?

like image 589
ACP Avatar asked Dec 13 '25 07:12

ACP


1 Answers

$('#form input').attr('value','');

Resetting radio buttons and checkboxes:

$('#form input[type=radio]').attr('checked','');

Might be easier to combine that to:

$('#form input').attr('value','').attr('checked','');

But if it's for all the possible options, this should work too:

$('#form').each(function() {
  this.reset();
});
like image 113
Alec Avatar answered Dec 14 '25 20:12

Alec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!