zoukankan      html  css  js  c++  java
  • 通过js 向table添加或修改row及cell

    //取得table对象
            var tabObj = document.getElementById("tabTipResult");
        //目前table有多少行
            var rowCount = tabObj.rows.length;
        //每行有多少列
            var cellCount = tabObj.rows(0).cells.length;

            if(rowCount < pageCount)
            {
                for(var i=0;i< pageCount ;i++)
                {
            //循环 向table增加新行
                    var newRow = tabObj.insertRow(rowCount++);  
                    for(var j=0;j<cellCount;j++)          
                    {
                //每行的新列值    
                        newRow.insertCell(j).innerHTML="无";            
                    }
                }
            }
            else
            {
                for(var i=1;i<= pageCount ;i++)
                {
                    var tmpRow = tabObj.rows(i);  
                    for(var j=0;j<cellCount;j++)          
                    {
                        tmpRow.cells(j).innerHTML="无";            
                    }
            //该行的背景色属性
            tmpRow .onmouseout = function(){this.bgColo
    r="white";};
            tmpRow .onmouseover= function(){this.bgColor="#efffff";};
            //td 在 onclick事件
            tmpRow .cells(0).onclick = function(){ alert("");};   
                }
            }
  • 相关阅读:
    团队项目-选题报告
    第一次结对编程作业
    第一次个人编程作业
    第一次软工作业
    antd form表单数组对象格式
    antd form表单验证失去焦点时验证和重置验证状态
    fetch请求
    typescript类装饰器
    typescript泛型
    浮点数问题
  • 原文地址:https://www.cnblogs.com/freeliver54/p/600419.html
Copyright © 2011-2022 走看看