点击11111 22222 33333 44444都可以实现多选框选中,但是只有44444是单独的label ,11111 22222 33333十多个label对应一个多选框,CSS为input[type="checkbox"]:checked+label。只有44444能应用样式。
完整代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
input[type="checkbox"]:checked+label{
color: red;
}
</style>
</head>
<body>
<table>
<tr>
<td><input type="checkbox" id="check"></td>
<td><label for="check">11111</label></td>
<td><label for="check">22222</label></td>
<td><label for="check">33333</label></td> <br>
<input type="checkbox" id="ch"><label for="ch">444444444</label>
</tr>
</table>
</body>
</html>