JS——全选和全不选
2021-04-25 02:29
阅读:765
YPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
标签:type gre 返回 获取 script EDA 遍历 padding color
1、全选和全不选函数:
getElementById方法:返回对拥有指定ID的第一个对象的引用。
getElementsByName方法:返回带有指定名称的对象的集合。
序号 学号 姓名 平时成绩 期末成绩 学期总成绩 1 20100300201 张小丽 95 95 95 2 20100300202 李宁 90 88 89 3 20100300203 刘梅 98 92 95 4 20100300204 王刚 98 90 94 5 20100300205 郑军 90 85 87 6 20100300206 杨波 80 80 80
getElementById方法获取的是与属性在同一行的复选框的状态,如果已经选中就用getElementsByName方法获取一个集合,并对集合进行遍历将复选框的状态变为选中,否则,将复选框全部变为未选中。
2、完整代码:
"utf-8">全选和全不选
"checkbox" onclick="checkAll()" id="checkAll"/> | "blanchedalmond "align="middle" >序号 | "blanchedalmond "align="middle ">学号 | "blanchedalmond "align="middle ">姓名 | "blanchedalmond "align="middle ">平时成绩 | "blanchedalmond "align="middle ">期末成绩 | "blanchedalmond "align="middle ">学期总成绩 |
---|---|---|---|---|---|---|
"checkbox" name="checkOne"/> | "middle ">1 | "middle ">20100300201 | "middle ">张小丽 | "middle ">95 | "middle ">95 | "middle ">95 |
"checkbox" name="checkOne"/> | "grey "align="middle ">2 | "grey "align="middle ">20100300202 | "grey "align="middle ">李宁 | "grey "align="middle ">90 | "grey "align="middle ">88 | "grey "align="middle ">89 |
"checkbox" name="checkOne"/> | "middle ">3 | "middle ">20100300203 | "middle ">刘梅 | "middle ">98 | "middle ">92 | "middle ">95 |
"checkbox" name="checkOne"/> | "grey "align="middle ">4 | "grey "align="middle ">20100300204 | "grey "align="middle ">王刚 | "grey "align="middle ">98 | "grey "align="middle ">90 | "grey "align="middle ">94 |
"checkbox" name="checkOne"/> | "middle ">5 | "middle ">20100300205 | "middle ">郑军 | "middle ">90 | "middle ">85 | "middle ">87 |
"checkbox" name="checkOne"/> | "grey "align="middle ">6 | "grey "align="middle ">20100300206 | "grey "align="middle ">杨波 | "grey "align="middle ">80 | "grey "align="middle ">80 | "grey "align="middle ">80 |
JS——全选和全不选
标签:type gre 返回 获取 script EDA 遍历 padding color
原文地址:https://www.cnblogs.com/zhai1997/p/12230382.html
评论
亲,登录后才可以留言!