jQuery – Reset all inputs within a DIV

Found this really cool way of resetting all values within a DIV. A reset button can be used to reset the entire form, but I selectively wanted to reset only a section of the form so I couldn’t have used the reset button. Also – I wanted to do this as an event handler for select change so it worked out very well.

$div_ec = $( "#id_feature_ec" );
$div_ec.find('input[type="text"]').val('');
$div_ec.find('input[type="number"]').val('');
$div_ec.find('input[type="checkbox"]').attr('checked', false);
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s