记录一下,前台JS实现向指定表中添加行,并且定义样式:
<table id="projectList" class="project_list_table" style="text-align: left;">
</table>
这样写一个空表,
//动态添加项目数据
function addRow()
{
var rows = document.getElementById("projectList").rows.length;
//添加行
var newTr = projectList.insertRow(rows-1); //指定添加的位置
newTr.style.setAttribute("width","100%");//一种定义样式的写法
newTr.style.height="50px";//另外一种定义样式的写法
//添加2列
var newTd = newTr.insertCell();
var newTd2 = newTr.insertCell();
//第一列样式
newTd.style.setAttribute("width","85%");
newTd.style.setAttribute("font-size","20px");
//第二列样式
newTd2.style.setAttribute("text-align","center");
newTd2.style.setAttribute("