[英]enable multiple checkboxes when a checkbox is checked
I have 5 text boxes whose IDs and names are all different from each other. 我有5个文本框,它们的ID和名称互不相同。 But i have to enable all 5 text boxes when a certain checkbox is checked. 但是,当选中某个复选框时,我必须启用所有5个文本框。 How do i do this with JavaScript? 如何使用JavaScript执行此操作?
With jQuery you can do 使用jQuery,您可以做
<input id="check" type="checkbox" value=""><br>
<input type="text" value="" disabled="disabled"><br>
<input type="text" value="" disabled="disabled"><br>
<input type="text" value="" disabled="disabled"><br>
var $input = $('input[type="text"]');
$('#check').live('click', function() {
$(this).is(':checked') ? $input.removeAttr('disabled') : $input.attr('disabled', 'disabled');
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.