简单table单元设置,颜色渐变,元素获取

来源:互联网 发布:如何在mac里打开终端 编辑:程序博客网 时间:2024/06/04 07:02
//jquery与js结合,$里面可以是对象,也可以是标签,id
var input = cells[j].getElementsByTagName("input");

$(input[0]).attr("style", "background-color:#fff;");


==============================================================
function bgChange(){
for (var j=1;j<=2;j++){
var bb = document.getElementById('editTable');


var cc = bb.getElementsByTagName('tr');

//var dd = bb.getElementsByTagName('td');
for (var i=3;i< cc.length;i++){
//for(var j=3;j<dd.length;;j++){
var cells = cc[i].getElementsByTagName("td");

for(var j=0;j<cells.length;j++){
var input = cells[j].getElementsByTagName("input");
//cells[j].className = (i%2==0)? 'hui' : 'white';

if(i%2==0){
//$('input').style.cssText="background-color:#fff;"

$(input[0]).attr("style", "background-color:#fff;");
$(input[1]).attr("style", "background-color:#fff;");
$(input[2]).attr("style", "background-color:#fff;");
}else{
//input.style.cssText="background-color:#888;"
$(input[0]).attr("style", "background-color:#ccc;");
$(input[1]).attr("style", "background-color:#ccc;");
$(input[2]).attr("style", "background-color:#ccc;");
}

}
}
}
  }


$(function(){

if(id){
setTimeout("bgChange()",1000);
}
//window.setTimeout("document.getElementById('mainDiv').scrollIntoView(true)", 500);


}); 


<table id="editTable" class="zftable zflist" border="1">
<tr class='row_title'>
<td width="12%" nowrap rowspan="2">日期</td>
<td width="6%" nowrap rowspan="2">周</td>
<td width="6%" nowrap rowspan="2">餐别</td>
<td width="56%" nowrap colspan="4">菜谱名称</td>
<td width="10%" nowrap rowspan="2">管教干警</td>
<td width="10%" nowrap rowspan="2">看守干警</td>
</tr>
<tr class='row_title'>
<td width="14%" nowrap>菜名</td>
<td width="14%" nowrap>菜名111</td>
<td width="14%" nowrap>菜名</td>
<td width="14%" nowrap>加餐</td>
</tr>
</table>
0 0
原创粉丝点击