我正在寻找检查所有复选框并找到答案,但是当我将代码从小提琴演示复制到普通的 html 页面并在 WAMP 服务器中执行代码时,它不起作用。
这是代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> check all</title>
<script type="text/javascript">
$('.chk_boxes').click(function(){
var chk = $(this).attr('checked')?true:false;
$('.chk_boxes1').attr('checked',chk);
});
</script>
</head>
<body>
<form>
<table>
<tr class="table_head_seperator">
<td class="grid_info" width="32px" bgcolor="#f6f6f6"><input type="checkbox" class="chk_boxes1" name="to_delete[<?PHP echo $entry['id'] ?>]" /></td>
<td class="grid_info" width="160px" bgcolor="#eeeeee"><span class="country_name">user name</span></td>
<td class="grid_info" width="130px" bgcolor="#eeeeee"><span class="country_name">date created</span></td>
<td class="grid_info" width="100px" bgcolor="#f6f6f6"><span class="country_name">username</span></td>
</tr>
<tr class="table_head_seperator">
<td class="grid_info" width="32px" bgcolor="#f6f6f6"><input type="checkbox" class="chk_boxes1" name="to_delete[<?PHP echo $entry['id'] ?>]" /></td>
<td class="grid_info" width="160px" bgcolor="#eeeeee"><span class="country_name">user name</span></td>
<td class="grid_info" width="130px" bgcolor="#eeeeee"><span class="country_name">date created</span></td>
<td class="grid_info" width="100px" bgcolor="#f6f6f6"><span class="country_name">username</span></td>
</tr><tr class="table_head_seperator">
<td class="grid_info" width="32px" bgcolor="#f6f6f6"><input type="checkbox" class="chk_boxes1" name="to_delete[<?PHP echo $entry['id'] ?>]" /></td>
<td class="grid_info" width="160px" bgcolor="#eeeeee"><span class="country_name">user name</span></td>
<td class="grid_info" width="130px" bgcolor="#eeeeee"><span class="country_name">date created</span></td>
<td class="grid_info" width="100px" bgcolor="#f6f6f6"><span class="country_name">username</span></td>
</tr>
</table>
<input type="checkbox" class="chk_boxes" label="check all" />check all
</form>
</body>
</html>