Reputation: 29
I'd like to know if someone can help me, i've been trying to enable various inputs from a checkbox button of bootstrap, here is an example http://jsfiddle.net/FArMm/1031/.
EDIT
I found a solution, if someone ever need to do something similar, here is the code http://jsfiddle.net/jc4QD/1/
Upvotes: 2
Views: 6298
Reputation: 2774
Check this fiddle: http://jsfiddle.net/FArMm/1033/
You need to enclose your fields in a <form>
tag
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-primary active">
<form>
<input type="checkbox" id="test">Activate</label>
</div>
<input type="text" disabled="disabled" class="prueba" />
<input type="text" disabled="disabled" class="prueba" />
<input type="text" disabled="disabled" class="prueba" />
<input type="text" disabled="disabled" class="prueba" />
</form>
The use the .each()
function:
$('#test').click(function () {
var checked = this.checked;
console.log(checked);
$('.prueba').each(function () {
$(this).prop('disabled', !checked);
});
});
Upvotes: 2