zoukankan      html  css  js  c++  java
  • javascript: change the content of table

    1.change content 

    var table = document.getElementById("TableData1");
     var enab = document.getElementById("alr_"+alr_id).value;
     table.rows[tab_line].cells[0].innerHTML="<input type='checkbox' class='standardTxt' id='set_enab' "+(enab=="true"?"checked":"")+" />";
     

    2. insert row

    function addRow()

    {

      //添加一行

      var newTr = testTbl.insertRow();

      //设置行背景

      newTr.bgColor = '#008040';

      //添加两列

      var newTd0 = newTr.insertCell();

      var newTd1 = newTr.insertCell();

      //设置列内容和属性

      newTd0.innerHTML = '<input type=checkbox id="box4">';

      newTd1.innerText= '新增加的行';
    }
    </script>

    3. dom insert row

    var tb = document.getElementById("mailtable");
     var row = document.createElement("tr");
     var cell0 = document.createElement("td");
     cell0.className = "standardTxt";
      cell0.innerHTML = "a";
     var cell1 = document.createElement("td");
     cell1.align = "right";
     cell1.className = "standardTxt";
     cell1.innerHTML = ";
     row.appendChild(cell0);
     row.appendChild(cell1);
     tb.tBodies[0].appendChild(row);

    4. add more rows

    function insertRows(rows){
     document.getElementById("div_mailtable").innerHTML=
      "<table id='mailtable' width='100%' cellpadding=0 cellspacing=0 border=0>"
      +"<tbody id='body_mailtable'>"+document.getElementById("mailtable").tBodies[0].innerHTML+rows+"</tbody></table>";
    }

  • 相关阅读:
    8.16
    8.6 总结
    Educational Codeforces Round 45 (Rated for Div. 2)
    Codeforces Round #487 (Div. 2)
    Codeforces Round #485
    codeforces Avito Code Challenge 2018
    MySQL索引知识面试题
    使用多线程优化复杂逻辑以及数据量多处理
    elasticsearch 和Ik 以及 logstash 同步数据库数据
    linux 安装elasticsearch步骤以及入的坑
  • 原文地址:https://www.cnblogs.com/kevinge/p/1544874.html
Copyright © 2011-2022 走看看