Aanu
Aanu

Reputation: 4219

reset group of form fields - jquery

I would like to reset the values of one set of form fields which belongs to the same class. for example,

<input type="checkbox" name"abc" id="abc" class="class1">
<input type="text" name"abc1" id="abc1" class="class1">
<input type="checkbox" name"abc2" id="abc2" class="class1">

onclick of another checkbox, I would like to reset the above 3 fields. Please help.

Upvotes: 0

Views: 330

Answers (2)

Aron Rotteveel
Aron Rotteveel

Reputation: 83163

$('#somecheckbox').click(function() { 
    $('input.class1').attr('checked', false);
});

Upvotes: 2

marcgg
marcgg

Reputation: 66436

I'd do this on document ready :

jQuery("#abc").bind("click", function(this){
  jQuery( "." + jQuery(this).attr("class") ).val("");
});

Upvotes: 0

Related Questions