动态改变交替tr背景色 存在display隐藏行 那你就不要用css设置了应该display设置好以后,判断一下,然后js设置className 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 没有思路,只有代码!L@_@K<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head> <title> new document </title> <meta name="generator" content="editplus" /> <meta name="author" content="Gao YiXiang" /> <meta name="email" content="[email protected]" /> <meta name="keywords" content="javascript dhtml dom" /> <meta name="description" content="I love web development." /> <style type="text/css">.firstRow{ background-color: #ffff00;}.secondRow{ background-color: #dddddd;} </style></head><body> <table id="tbeColor" width="100%"> <tr> <td>1</td> <td>1</td> </tr> <tr> <td>2</td> <td>2<input type="button" value="hide row" onclick="this.parentNode.parentNode.style.display='none';refreshStyle('tbeColor');" /></td> </tr> <tr> <td>3</td> <td>3<input type="button" value="hide row" onclick="this.parentNode.parentNode.style.display='none';refreshStyle('tbeColor');" /></td> </tr> <tr> <td>4</td> <td>4</td> </tr> <tr> <td>5</td> <td>1</td> </tr> <tr> <td>6</td> <td>2</td> </tr> <tr> <td>7</td> <td>3</td> </tr> <tr> <td>8</td> <td>4</td> </tr> </table></body><script type="text/javascript"><!--function refreshStyle(sTableId){ var oRows = document.getElementById(sTableId).rows; var currentClass = "secondRow"; for (var i=0; i<oRows.length; i++) { if (oRows[i].style.display != "none") { if (currentClass == "secondRow") currentClass = "firstRow"; else currentClass = "secondRow"; oRows[i].className = currentClass; } } }refreshStyle("tbeColor");//--></script></html> <style type="text/css">#t {width:100%;}.a {background:red;}.b {background:orange;}</style><table id="t"><tr><td class="a"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr><tr><td class="b"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr><tr><td class="a"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr><tr><td class="b"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr></table><script type="text/javascript">function hide(rowobj){//下班先;}</script> 更新一下refreshStyle,第一版太啰嗦!function refreshStyle(sTableId){ var oRows = document.getElementById(sTableId).rows; var currentClass = "firstRow"; for (var i=0; i<oRows.length; i++) { if (oRows[i].style.display != "none") { oRows[i].className = currentClass; currentClass = currentClass=="firstRow" ? "secondRow" : "firstRow"; } } } 一段代码··新手求注释 jquery中$是指什么意思? Ext 2.3 树 treeloader 无法加载 关于XML HTTP 的疑问 麻烦下这个问题怎么解决呀? 求 如何用JS屏蔽右键 关于一个下拉菜单的隐藏问题? 还是刚才的关于options.remove()的问题,开个新帖 急,高手請進,為什麼radio的onSelect事件不響應? 用javascript怎么输出双引号(")! 为什么有些JS代码在 windows 2003 server下运行正常,在2000 server下出错呢? 循环中的setInterval的问题
L@_@K
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title> new document </title>
<meta name="generator" content="editplus" />
<meta name="author" content="Gao YiXiang" />
<meta name="email" content="[email protected]" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
<style type="text/css">
.firstRow
{
background-color: #ffff00;
}
.secondRow
{
background-color: #dddddd;
}
</style>
</head>
<body>
<table id="tbeColor" width="100%">
<tr>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>2</td>
<td>2<input type="button" value="hide row" onclick="this.parentNode.parentNode.style.display='none';refreshStyle('tbeColor');" /></td>
</tr>
<tr>
<td>3</td>
<td>3<input type="button" value="hide row" onclick="this.parentNode.parentNode.style.display='none';refreshStyle('tbeColor');" /></td>
</tr>
<tr>
<td>4</td>
<td>4</td>
</tr>
<tr>
<td>5</td>
<td>1</td>
</tr>
<tr>
<td>6</td>
<td>2</td>
</tr>
<tr>
<td>7</td>
<td>3</td>
</tr>
<tr>
<td>8</td>
<td>4</td>
</tr>
</table>
</body>
<script type="text/javascript">
<!--
function refreshStyle(sTableId)
{
var oRows = document.getElementById(sTableId).rows;
var currentClass = "secondRow";
for (var i=0; i<oRows.length; i++)
{
if (oRows[i].style.display != "none")
{
if (currentClass == "secondRow")
currentClass = "firstRow";
else
currentClass = "secondRow"; oRows[i].className = currentClass;
}
}
}
refreshStyle("tbeColor");
//-->
</script>
</html>
#t {width:100%;}
.a {background:red;}
.b {background:orange;}
</style><table id="t">
<tr><td class="a"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr>
<tr><td class="b"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr>
<tr><td class="a"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr>
<tr><td class="b"><input type="button" value="隐藏" onclick="hide(this.parentNode.parentNode);"></td></tr>
</table><script type="text/javascript">
function hide(rowobj){
//下班先;
}
</script>
function refreshStyle(sTableId)
{
var oRows = document.getElementById(sTableId).rows;
var currentClass = "firstRow";
for (var i=0; i<oRows.length; i++)
{
if (oRows[i].style.display != "none")
{
oRows[i].className = currentClass; currentClass = currentClass=="firstRow" ? "secondRow" : "firstRow";
}
}
}