请帮助我想启用选择与复选框,如果在该行中检查复选框。该代码仅在第一行内工作,但其余的不起作用。我的复选框的ID是roomCheck和名称是chkbox启用选择选项内的行复选框
<table name = "mytab1" id = "MyTable" border = "1">
<tr>
<td><input type = "checkbox" name = "chkbox" id = "roomCheck"></td>
<td><select id = "number" disabled><option>test</option></select>
</tr>
<tr>
<td><input type = "checkbox" name = "chkbox"></td>
<td><select id = "number" disabled><option>test</option></select>
</tr>
<tr>
<td><input type = "checkbox" name = "chkbox" id = "roomCheck"></td>
<td><select id = "number" disabled><option>test</option></select>
</tr>
<tr>
<td><input type = "checkbox" name = "chkbox" id = "roomCheck"></td>
<td><select id = "number" disabled><option>test</option></select>
</tr>
<tr>
<td><input type = "checkbox" name = "chkbox" id = "roomCheck"></td>
<td><select id = "number" disabled><option>test</option></select>
</tr>
<tr>
<td><input type = "checkbox" name = "chkbox" id = "roomCheck"></td>
<td><select id = "number" disabled><option>test</option></select>
</tr>
</table>
<script src="jquery.min.js"></script>
<script language="JavaScript">
var update = function() {
if ($("#roomCheck").is(":checked")) {
$('#number').prop('disabled', false);
}
else {
$('#number').prop('disabled', 'disabled');
}
};
$(update);
$("#roomCheck").change(update);
</script>
</script>
我们使用的'id's单独列出项目的代码。使用不同的ID或使用类名称。 –
这是需要的目标吗? https://jsfiddle.net/oo3b9zm2/1/ –
实现它的方法之一是通过@whitelettersinblankpapers提供的示例 – alariva