zoukankan      html  css  js  c++  java
  • HTML动态操作表格

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>动态操作表格</title>
    <script>
    var flag=false,number=2;
    function addRow(){
        flag=!flag;
        //添加一行
        var newTr=table1.insertRow(table1.rows.length);
        //添加两列
        var newTd0=newTr.insertCell();
        var newTd1=newTr.insertCell();
        //设置列内容和属性
        if(flag){
            newTr.style.backgroud="E0FFFF";
        }
        else{
            newTr.style.backgroud="90FF90";
        }
        number++;
        newTd0.innerText=""+number+"";
    }
    function delRow(){
        if(number>1){
            
            flag=!flag;
            table1.deleteRow(table1.rows.length-1);
            number--;
        }
    }
    
    </script>
    </head>
    
    <body>
    <table width="200" cellspacing="1" id="table1" style="font-size:14px; border:1px solid #cad9ea;">
    <tr bgcolor="#90EE90">
    <td>第1行</td>
    <td></td>
    </tr>
    <tr bgcolor="#909090">
    <td>第2行</td>
    <td></td>
    </tr>
    </table>
    <input type="button" value="插入行" onClick="addRow()"/>&nbsp;&nbsp;
    <input type="button" value="删除行" onClick="delRow()"/>
    </body>
    </html>
  • 相关阅读:
    linux动态库加载路径修改
    RAII手法封装互斥锁
    比特数组
    c++行事准则
    构造函数初始化列表
    this与const
    不完全类型
    Django初学习(四):模板-上下文管理器的使用
    Django初学习(三):模板的使用
    Django初学习(二):路由&子路由
  • 原文地址:https://www.cnblogs.com/chuanzi/p/10888219.html
Copyright © 2011-2022 走看看