如何设置红色字体中内容的css属性?就像 table1.setAttribute("fontalign","center");
<html>
<head>
<title>dom</title>
</head>
<style type="text/css">
<!--
.td{
border:solid 1px #000000;
}
-->
</style>
<script language="javascript">
function maketable()
{
var table1=document.createElement("table"); //创建一个TABLE 标签 也可以是 DIV
table1.setAttribute("border","1");
table1.setAttribute("width","60%");
table1.style.setAttribute("border","solid 2px #000000");
table1.setAttribute("id","table11");
table1.style.setAttribute("backgroundColor","#ffff00");
table1.style.setAttribute("margin","30");
table1.setAttribute("align","center");
table1.setAttribute("fontalign","center");
document.body.appendChild(table1);
var header=table1.createTHead();
var headerrow=header.insertRow(0);
headerrow.insertCell(0).appendChild(document.createTextNode("姓名"));
headerrow.insertCell(1).appendChild(document.createTextNode("年龄"));
headerrow.insertCell(2).appendChild(document.createTextNode("性别"));
for (var i=1;i<4;i++)
{
var headerrow=header.insertRow(i);
headerrow.insertCell(0).appendChild(document.createTextNode("cnn"));
headerrow.insertCell(1).appendChild(document.createTextNode("99"));
headerrow.insertCell(2).appendChild(document.createTextNode("男"));
}
}
</script>
<body>
<span onclick="maketable();">测试</span>
</body>
</html>