我想实现通过点击按钮改变颜色来实现上下切换的功能
由于对javascript不太了解,所以请大家帮忙了
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.abc {
font-size: 14px;
color: #339966;
font-weight: bold;
}
.cba {
font-size: 14px;
color: #FF0000;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table width="275" height="92" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="59" height="31" class="abc" id="m_1" style="background-color:#FFCC66" >aaaa</td><a id="sumnum" style="display:none" >3</a>
</tr>
<tr>
<td height="31" class="cba" id="m_2" style="background-color:#CCCCCC">bbbb</td>
</tr>
<tr>
<td height="30" class="cba" id="m_3" style="background-color:#CCCCCC">cccc</td>
</tr>
</table>
<p>
<label></label>
<input type="button" name="Submit" value="change" onclick="change();" />
</p>
<script language="javascript">
function change(){
var totalnumber;
var j;
var chindex;
totalnumber=parseInt(document.all.sumnum.innerText);
if (j<totalnumber){
chindex=eval("m_"+j);
document.all.chindex.style.background-color="#CCCCCC";
j++;
chindex=eval("m_"+j);
document.all.chindex.style.background-color="#FFCC66";
}
}
</script>
</body>
</html>