<!DOCTYPE Html> |
02 |
<html>
|
03 |
<head>
|
04 |
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
|
05 |
<script type="text/javascript">
|
06 |
function selectAll(checkbox) {
|
07 |
$('input[type=checkbox]').attr('checked', $(checkbox).attr('checked'));
|
08 |
}
|
09 |
</script>
|
10 |
</head>
|
11 |
<body>
|
12 |
<input type="checkbox" onclick="selectAll(this);" />全选<br/>
|
13 |
<input type="checkbox" /><br/>
|
14 |
<input type="checkbox" /><br/>
|
15 |
<input type="checkbox" /><br/>
|
16 |
<input type="checkbox" /><br/>
|
17 |
<input type="checkbox" /><br/>
|
18 |
<input type="checkbox" /><br/>
|
19 |
……
|
20 |
</body>
|
21 |
</html>
|
本文介绍了一种利用jQuery简化DOM操作的方法,通过一个全选按钮控制页面上所有复选框的状态。此方法适用于需要批量操作元素的场景,提高了前端交互的效率。
1017

被折叠的 条评论
为什么被折叠?



