<script language="JavaScript" type="text/JavaScript">
<!-- Begin
function showNewColor() {
// setup vars
var defaultColor = "white";
var newColor = "#ff9999";
if((document.getElementById)&& (document.getElementById('tagID')!=null)) {
// Get a reference to the element
var myElement = document.getElementById('tagID');
// Check the element's style object and background property are available
if ((myElement.style)&& (myElement.style.backgroundColor!=null)) {
// Check the value of the property
if(myElement.style.backgroundColor == 'white'){
// change style to new color
document.getElementById('tagID').style.backgroundColor = newColor;
}else {
// change style to default color
document.getElementById('tagID').style.backgroundColor = defaultColor;
}
}else {
// This CSS property is not assigned or is not supported
return;
}
}else {
return;
}
}
// End --->
</script>
<table id="tagID" style="background-color:white;" width="200" height="50" cellspacing="2" cellpadding="2">
<tr><td>这里是具体的内容
</td></tr>
</table>
<br><a href="javascript:showNewColor();">变换背景色</a>