[jQuery] toggle and checkbox
Using jquery 1.2.1 toggle:
jQuery().ready(function(){
$('#multiple').toggle(
function(){
$('.afield').attr('disabled',true);
},
function(){
$('.afield').removeAttr('disabled');
}
);
});
I'm trying to toggle the disabled attribute of some text input boxes
based on a checkbox input:
<form>
<input id="multiple" type="checkbox">The Toggle</input>
<input type="text" class="afield">
</form>
However, when the checkbox is clicked, the check does not appear.
Fails in IE and Firefox.
I've tried adding code to check the box, but that fails as well.
jQuery().ready(function(){
$('#multiple').toggle(
function(){
$('#multiple').attr('checked',true);
$('.afield').attr('disabled',true);
},
function(){
$('#same').removeAttr('checked');
$('.afield').removeAttr('disabled');
}
);
});
What's the best way to accomplish disabling text inputs with a
checkbox? Am I overthinking this?
Any help would sure be appreciated.