js 取行

来源:互联网 发布:销售数据分析表格 编辑:程序博客网 时间:2024/06/06 03:30

留下看看

 

var stafferList1 = parent.frame1.document.getElementById("stafferList");
      var stafferList2 = parent.frame2.document.getElementById("stafferList");
      if(stafferList1 && stafferList2){
       for(var i=0;i<stafferList1.rows.length;i++){
           if(stafferList1.rows.item(i).cells.length != stafferList2.rows.item(i).cells.length){
               for(var j=0;j<stafferList1.rows.item(i).cells.length;j++ ){
            stafferList1.rows.item(i).cells.item(j).style.backgroundColor = "yellow";
         }
            for(var j=0;j<stafferList2.rows.item(i).cells.length;j++ ){
            stafferList2.rows.item(i).cells.item(j).style.backgroundColor = "yellow";
         }
               continue;
           }
           var strTrue = false;
        for(var j=0;j<stafferList1.rows.item(i).cells.length;j++ ){
           var value1=stafferList1.rows.item(i).cells.item(j).innerText;
           var value2=stafferList2.rows.item(i).cells.item(j).innerText;
           if(value1 != value2){
              strTrue = ture;
           }
        }
       
        if(strTrue){
            for(var j=0;j<stafferList1.rows.item(i).cells.length;j++ ){
            stafferList1.rows.item(i).cells.item(j).style.backgroundColor = "yellow";
         }
            for(var j=0;j<stafferList2.rows.item(i).cells.length;j++ ){
            stafferList2.rows.item(i).cells.item(j).style.backgroundColor = "yellow";
         }
        }
       }
      }
     
      var scheduleList1 = parent.frame1.document.getElementById("scheduleList");
      var scheduleList2 = parent.frame2.document.getElementById("scheduleList");
      if(scheduleList1 && scheduleList2){
       for(var i=0;i<scheduleList1.rows.length;i++){
           if(scheduleList1.rows.item(i).cells.length != scheduleList2.rows.item(i).cells.length){
              for(var j=0;j<scheduleList1.rows.item(i).cells.length;j++ ){
                scheduleList1.rows.item(i).cells.item(j).style.backgroundColor = "yellow";
           }
              for(var j=0;j<scheduleList2.rows.item(i).cells.length;j++ ){
                scheduleList2.rows.item(i).cells.item(j).style.backgroundColor = "yellow";
           }
              continue;
           }
           var strTrue = false;
        for(var j=0;j<scheduleList1.rows.item(i).cells.length;j++ ){
           var value1=scheduleList1.rows.item(i).cells.item(j).innerText;
           var value2=scheduleList2.rows.item(i).cells.item(j).innerText;
           if(value1 != value2){
              strTrue = true;
           }
        }
        if(strTrue){
             for(var j=0;j<scheduleList1.rows.item(i).cells.length;j++ ){
                scheduleList1.rows.item(i).cells.item(j).style.backgroundColor = "blue";
           }
              for(var j=0;j<scheduleList2.rows.item(i).cells.length;j++ ){
                scheduleList2.rows.item(i).cells.item(j).style.backgroundColor = "blue";
           }
        }
       }
      }

 

1    var trElement = document.createElement("tr");
   2    var tdElement = document.createElement("td");
   3    tdElement.colSpan = 6;
   4    tdElement.innerHTML = "没有在线用户";
   5    trElement.appendChild(tdElement);


   6    var tBody = document.getElementById("mytBodyId");


  7   tBody.appendChild(trElement);

 

第3行,很多人会写成tdElement.colspan = 6;,是无效的。

第2行,很多人会写成trElement.innerHTML = "《td colspan=6》没有在线用户《/td》";,是无效的。

第4行,是没问题的,也可以再创建一个文本节点然后用tdElement.appendChild()添加。

第7行,很多人会写成tBody.innerHTML = "《tr》《td colspan=6》没有在线用户《/td》《/tr》";,是无效的.