i want to toggle disable property of a checkbox group based on other checkbox checked property Html code for checkbox group is is :
<div class="checkbox-group">
<div class="col1">
<p>
<input type="checkbox" name="backpack" id="backpack" tabindex="170" />
<label for="backpack">Backpack Cal</label>
</p>
<p>
<input type="checkbox" name="calm" id="calm" tabindex="180" />
<label for="calm">California Calm</label>
</p>
<p>
<input type="checkbox" name="hotsprings" id="hotsprings" tabindex="190" />
<label for="hotsprings">California Hotsprings</label>
</p>
</div>
<div class="col2">
<p>
<input type="checkbox" name="cycle" id="cycle" tabindex="210" />
<label for="cycle">Cycle California</label>
</p>
<p>
<input type="checkbox" name="desert" id="desert" tabindex="220" />
<label for="desert">From Desert to Sea</label>
</p>
<p>
<input type="checkbox" name="kids" id="kids" tabindex="230" />
<label for="kids">Kids California</label>
</p>
</div>
<div class="col3">
<p>
<input type="checkbox" name="nature" id="nature" tabindex="240" />
<label for="nature">Nature Watch</label>
</p>
<p>
<input type="checkbox" name="snowboard" id="snowboard" tabindex="250" />
<label for="snowboard">Snowboard Cali</label>
</p>
<p>
<input type="checkbox" name="taste" id="taste" tabindex="260" />
<label for="taste">Taste of California</label>
</p>
</div>
</div>
Html code for toggle button is
<div id="group-toggle">
<input type="checkbox" name="bike_check" id="bike_check" /> <label for="bike_check">I own, or will otherwise provide, my own bicycle</label>
</div>
And jquery code is
var $checkbox= $('.checkbox-group').find('input[type=checkbox]');
$checkbox.prop('disabled',true);
$('#bike_check').click(function() {
var $toggle=$(this);
});
$checkbox.prop('disabled',!$toggle.prop('checked'));
i am able to do it using if-else statement but not by this ,what thing i am doing wrong
Aucun commentaire:
Enregistrer un commentaire