如何设置红色字体中内容的css属性?就像 table1.setAttribute("fontalign","center");

cnnindexx 2009-04-02 10:35:34
<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>
...全文
451 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
junior_wu 2009-04-09
  • 打赏
  • 举报
回复
学习中~!
sohighthesky 2009-04-08
  • 打赏
  • 举报
回复
不对如果没记错的话,应该是这样的
headerrow.style.cssText="padding-left:2%;text-align:left;";
sohighthesky 2009-04-08
  • 打赏
  • 举报
回复
来晚了,
saisky 2009-04-04
  • 打赏
  • 举报
回复
headerrow.cssText = 'margin:0;font-size:12px';
铁樵 2009-04-03
  • 打赏
  • 举报
回复
headerrow.setAttribute("Style","color:Green;font-size:9pt");
或者
headerrow.style.color="Green";

52,782

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧