如何用Javascript设定页面中表格的样式? document.getElementsByTagName("TABLE")[0].className="xxx" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 你可以写一段函数,test()function test(){document.getElementsByTagName("TABLE")[0].className="xxx"//把每个要设定的放到这里.....}<body onload="test()"> 感谢!<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><title>Untitled Document</title><style type="text/css"><!--.ActionBar { color: #FFFFFF; background-color: #000000;}--></style><script language="JavaScript">function setActionStyle(){document.getElementsByTagName("TABLE")[0].className="ActionBar"}</script></head><body onLoad="setActionStyle()">Table 1<table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td>hello</td> <td>world</td> </tr></table>Table 2<table width="300" border="0" cellspacing="0" cellpadding="0"> <tr> <td>hello</td> <td>world</td> </tr></table></body></html> .load后面加载的类型? jquery调用load()函数,刷新后无效问题 JS赋值无效,在线等,急!!! 两个代码文件让JavaScript程序员爱上Python,谨此献给JavaScript战斗者。 请教JS中的初级问题--特权方法 javascript数组 組合的表格如何有對角線? 如何选中文本框中的文本 在不同的输入法下,0-9数字键的键码会不同吗? test search match这三个方法有什么区别啊? applet与javascript通信的问题,望高手指点! src 的问题
function test()
{
document.getElementsByTagName("TABLE")[0].className="xxx"
//把每个要设定的放到这里.....
}
<body onload="test()">
<html>
<head>
<title>Untitled Document</title>
<style type="text/css">
<!--
.ActionBar {
color: #FFFFFF;
background-color: #000000;
}
-->
</style>
<script language="JavaScript">
function setActionStyle()
{
document.getElementsByTagName("TABLE")[0].className="ActionBar"
}
</script>
</head><body onLoad="setActionStyle()">
Table 1
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>hello</td>
<td>world</td>
</tr>
</table>
Table 2
<table width="300" border="0" cellspacing="0" cellpadding="0">
<tr>
<td>hello</td>
<td>world</td>
</tr>
</table>
</body>
</html>