我在下面写了一个代码。我在这里要做的是,当三个正确的单元格被选中时,它应该显示一条消息说“Right”,如果没有,那么应该说“再试一次”。到目前为止,我的代码只突出显示了单元格。我想知道下一步我该如何进行?
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style>
table {
width:400px;
font-family:Verdana, Arial, Helvetica, sans-serif;
border:1px solid #000;
}
table td {border:1px solid #000;}
.bgrd {background-color:#CCCCCC;cursor:pointer;}
.bgrd_selected {background-color:#FFCC00;cursor:pointer;}
</style>
<script type="text/javascript">
function setColor(what)
{
var thetds = document.getElementsByTagName('td');
for(var i = 0; i < thetds.length; i++)
{
if(thetds[i].className == 'bgrd_selected')
{
thetds[i].className = 'bgrd';
}
}
what.className = 'bgrd_selected';
}
</script>
</head>
<body>
<table cellspacing="0" cellpadding="0">
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
<tr>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
<td class="bgrd" onclick="setColor(this)">
Select</td>
</tr>
</table>
</body>
</html>
谢谢