• js学习——1


    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>表格全选</title>
    <style>
    table{
    border: 1px solid;
    500px;
    margin-left: 30%;
    }
    td,th{
    text-align: center;
    border: 1px solid;
    }
    div{
    margin-top:10px;
    margin-left: 30%;
    }
    .out{

    }
    </style>
    <script>
    /**/
    //1、在页面加载完后绑定事件
    window.onload=function () {
    //2、给全选按钮绑定事件
    document.getElementById("unSelectAll").onclick= function () {
    //3、遍历全部的属性将未选中设置为选中
    var cbs=document.getElementsByName("cd");
    for (var i=0;i<cbs.length;i++){
    cbs[i].spellcheck=false;
    }
    }
    document.getElementById("selectall").onclick= function () {
    //3、遍历全部的属性将未选中设置为选中
    var cbs=document.getElementsByName("cd");
    for (var i=0;i<cbs.length;i++){
    cbs[i].spellcheck=true;
    }
    }
    document.getElementById("selcetRev").onclick= function () {
    //3、遍历全部的属性将未选中设置为选中
    var cbs=document.getElementsByName("cd");
    for (var i=0;i<cbs.length;i++){
    cbs[i].spellcheck=false;
    }
    }
    document.getElementById("firstCB").onclick= function () {
    //3、遍历全部的属性将未选中设置为选中
    var cbs=document.getElementsByName("cd");
    alert(this);
    for (var i=0;i<cbs.length;i++){
    cbs[i].spellcheck=false;
    }
    }
    document.getElementsByTagName("tr"){
    for (var i=0;i<trs.length;i++){

    }
    }
    }
    </script>
    </head>
    <body>
    <table>
    <caption>学生信息表</caption>
    <tr>
    <th><input type="checkbox" name="cd" id="firstCB"></th>
    <th>编号</th>
    <th>姓名</th>
    <th>性别</th>
    <th>操作</th>
    </tr>

    <tr>
    <td><input type="checkbox" name="cd"></td>
    <td>1</td>
    <td>令狐冲</td>
    <td>男</td>
    <td><a href="javascript:void(0)">删除</a></td>
    </tr>
    <tr>
    <td><input type="checkbox" name="cd"></td>
    <td>2</td>
    <td>任我行</td>
    <td>男</td>
    <td><a href="javascript:void(0)"></a>删除</td>
    </tr>
    <tr>
    <td><input type="checkbox"></td>
    <td>3</td>
    <td>岳不群</td>
    <td>?</td>
    <td><a href="javascript:void(0)"></a> 删除</td>
    </tr>



    </table>
    <div>
    <input type="button" id="selectall" value="全选">
    <input type="button" id="unSelectAll" value="全不选">
    <input type="button" id="selcetRev" value="反选">
    </div>
    </body>
    </html>

  • 相关阅读:
    BZOJ3212 Pku3468 A Simple Problem with Integers(线段树区间求和、区间加模板)
    BZOJ2208 [Jsoi2010]连通数
    洛谷P3952 时间复杂度
    BZOJ1051 [HAOI2006]受欢迎的牛
    BZOJ4318 OSU!
    BZOJ1798 [Ahoi2009]Seq 维护序列
    BZOJ1483 [HNOI2009]梦幻布丁
    洛谷P1439 最长公共子序列(O(nlogn)最长公共子序列模板)
    BZOJ2429 [HAOI2006]聪明的猴子
    BZOJ3714 [PA2014]Kuglarz
  • 原文地址:https://www.cnblogs.com/soyadios/p/11963414.html
Copyright © 2020-2023  润新知