我已经使用 Javascript 动态创建了 html 表,但是当我在 Firefox 上运行它时它看起来不错,但是当我在 chrome 表布局上运行它时,它似乎不如 Firefox 好。
FireFox Image
Chrome Image
我希望表格布局看起来像 FireFox。
My Code
<script language="javascript">
i=1;
function dummy(chackValue)
{
var table=document.getElementById("dataTable");
var row1=table.insertRow();
var row2=table.insertRow();
var row3=table.insertRow();
var row4=table.insertRow();
var cell1=row1.insertCell(0);
var element1 = document.createElement("input");
cell1.rowSpan="4",'size','width="100px"';
cell1.innerHTML=" ";
cell1.align="center";
element1.type = "checkbox";
element1.name="chkbox";
element1.id="id_checkbox";
element1.onClick="changeDelete(this)";
//cell1.innerHTML=i++;
cell1.appendChild(element1);
var cell1=row2.insertCell(0);
cell1.innerHTML="Brand:  ";
var el = document.createElement('select');
var opt = document.createElement('option');
el.setAttribute('name', 'txtRow');
el.setAttribute('size', 'width="100px"');
cell1.appendChild(el);
var label = document.createTextNode('---Tablets---');
opt.setAttribute('value', 'item1value');
opt.appendChild(label);
//opt.onchange=itemChange(this);
el.appendChild(opt);
cell1.appendChild(el);
var cell2=row2.insertCell(1);
cell2.innerHTML="Dose:";
cell2.rowSpan="2";
var cell3=row2.insertCell(1);
cell3.innerHTML="Days:";
cell3.rowSpan="2";
var cell4=row2.insertCell(3);
cell4.rowSpan="2";
cell4.innerHTML="Qty:";
var cell1=row3.insertCell(0);
cell1.innerHTML="Generic: ";
var cell1=row4.insertCell(0);
cell1.innerHTML="Info:";
cell1.colSpan="2";
var cell2 = row4.insertCell(1)
cell2.innerHTML = "DosageInfo";
cell2.colSpan = "2";
}
<div id="replace" >
<center>
<input type="button" onclick="dummy()" value="Append Row"/>
<input type='button' value='Delete' onclick="changeDelete(dataTable)"/>
</center><br>
<table border="1px" style="width:800px" align="center" id="dataTable" >
</table>
</div>