61,112
社区成员
发帖
与我相关
我的任务
分享
<!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="yixianggao@126.com" />
<meta name="keywords" content="javascript dhtml dom" />
<meta name="description" content="I love web development." />
<style type="text/css">
td
{
background-color: white;
color: black;
}
</style>
</head>
<body>
<table border="1" width="100%">
<tr>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>3</td>
<td>4</td>
</tr>
</table>
<script type="text/javascript">
<!--
var oTds = document.getElementsByTagName("td");
for (var i=0; i<oTds.length; i++)
{
oTds[i].onmouseover = function()
{
this.style.backgroundColor = "red";
};
oTds[i].onmouseout = function()
{
this.style.backgroundColor = "white";
};
oTds[i].onclick = function()
{
if (this.currentStyle.backgroundColor != "black")
{
this.mouseoverFP = this.onmouseover;
this.onmouseover = null;
this.mouseoutFP = this.onmouseout;
this.onmouseout = null;
this.style.backgroundColor = "black";
}
else
{
this.onmouseover = this.mouseoverFP;
this.onmouseout = this.mouseoutFP;
this.style.backgroundColor = "red";
}
};
}
//-->
</script>
</body>
</html>