如何设置a'的高度;td';在javascript中使用CSS的数组中
我的问题是如何将50px的高度设置为新创建的“td” *我的完整代码如下如何设置a'的高度;td';在javascript中使用CSS的数组中,javascript,css,Javascript,Css,我的问题是如何将50px的高度设置为新创建的“td” *我的完整代码如下 cell=new Array(); //some code lines // here 'k' is number of a FOR LOOP and this part work well cell[k]=document.createElement('td'); cell[k].style.height="50px"; // problem occur in here 创建行 var myColumns= r
cell=new Array();
//some code lines
// here 'k' is number of a FOR LOOP and this part work well
cell[k]=document.createElement('td');
cell[k].style.height="50px"; // problem occur in here
创建行
var myColumns= result.array2[0];
var myRows= result.array2[1];
var cellData="";
var mmm=0;
var kkk=2;
row=new Array();
cell=new Array();
row_num=parseInt(myRows+1);
cell_num=parseInt(myColumns);
tab=document.createElement('table');
tab.id="newtable";
tab.border="5";
tbo=document.createElement('tbody');
“otherTopSection”是一个div id名称
cell[k].style.height="50px";
if(c==0){
cont=document.createTextNode( result.array2[kkk])
kkk++;
}else{
cont=document.createTextNode( result.array1[mmm])
mmm++;
}
cell[k].appendChild(cont);
row[c].appendChild(cell[k]);
}
tbo.appendChild(row[c]);
}
tab.appendChild(tbo);
看起来它没有附加到DOM中
这是一把小提琴那是什么问题?它应该会起作用。是否附加元素?这会起作用;但是一行的
元素的高度都相同;因此,如果有一个同级
具有更高的高度,那么行中的每个单元格都将是更高的,height.var cell=document.createElement('td');cell.style.height=“50px”;这段代码可以工作,但是试着用cell[k]数组替换它!!!谢谢,现在我了解了情况,上面是你的代码工作
for(k=0;k<cell_num;k++) {
cell[k]=document.createElement('td');
cell[k].style.height="50px";
if(c==0){
cont=document.createTextNode( result.array2[kkk])
kkk++;
}else{
cont=document.createTextNode( result.array1[mmm])
mmm++;
}
cell[k].appendChild(cont);
row[c].appendChild(cell[k]);
}
tbo.appendChild(row[c]);
}
tab.appendChild(tbo);
document.getElementById('otherTopSection').appendChild(tab);
cell[k]=document.createElement('td');
cell[k].style.height="50px";
someTr.appendChild(cell[k]);