<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.12.4.min.js"></script>
</head>
<body>
<table cellspacing="0" cellpadding="0" border="1">
<thead>
<tr>
<th>选择</th>
<th>名字</th>
</tr>
</thead>
<tbody id="tbody" class="ul">
<tr>
<td><input type="checkbox" class="checkbox"></td>
<td>名字1</td>
</tr>
<tr>
<td><input type="checkbox" class="checkbox"></td>
<td>名字2</td>
</tr>
</tbody>
</table>
</body>
<script>
/**
* 将复选框变成单选模式
*/
$("#tbody").find(".checkbox").each(function() {
$(this).click(function() {
if($(this).prop("checked")){
$(".checkbox").removeProp("checked");
$(this).prop("checked",true);
}
});
});
</script>
</html>
将一组复选框变成单选模式
于 2020-04-28 19:41:53 首次发布