<script>
function edit(em) {
var ch = em.value;
var ed = $("td.td" + ch).value;
if ($(ed).is(: checked)) {
$(this).show();
} else {
$(this).hide();
}
}
</script>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
</head>
<body>
<input type="checkbox" value="25" onclick="edit(this)">
<input type="checkbox" value="26" onclick="edit(this)">
<input type="checkbox" value="27" onclick="edit(this)">
<table>
<tr>
<td class="td25" value="25"><a href="#">Edit</a></td>
<td class="td26" value="26"><a href="#">Edit</a></td>
<td class="td27" value="27"><a href="#">Edit</a></td>
</tr>
</table>
</body>
</html>
最佳答案
这里有一个错误:
if($(ed).is(:checked))...
应该是:
if($(ed).is(':checked'))...
关于javascript - 复选框代码不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30274752/