請幫助我想啓用選擇與複選框,如果在該行中檢查複選框。該代碼僅在第一行內工作,但其餘的不起作用。我的複選框的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