function showDiv(divID)
{
if(divID == 'div_current')
{
div_current.style.display == "block";
div_used.style.display == "none";
}
else
{
div_used.style.display == "block";
div_current.style.display == "none";
}
}
{
if(divID == 'div_current')
{
div_current.style.display == "block";
div_used.style.display == "none";
}
else
{
div_used.style.display == "block";
div_current.style.display == "none";
}
}
if(id == 'div_current')
这句话有问题啊!
你定义的id是一个object,而div_current看样子是个变量
我试了,但还是不行,大家帮忙啊。
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Page</title>
</head>
<body>
<table>
<tr>
<td style="width: 398px; height: 136px">div_used
<img src="images/2.jpg" onclick="showDiv('div_used')" height="50" width="50"></td>
<td style="width: 398px; height: 136px">div_current
<img src="images/3.jpg" onclick="showDiv('div_current')" height="50" width="50"></td>
</tr>
<tr>
<td style="width: 398px; height: 138px">
<div id="div_current" style="display: block;">div_current
<img src="images/banner.jpg" height="50" width="50">
</div>
</td>
<td style="width: 398px; height: 138px">
<div id="div_used" style="display: none;">div_used
<img src="images/4.jpg" height="50" width="50">
</div>
</td>
</tr>
<tr>
<td style="width: 398px; height: 116px">
</td>
<td style="width: 398px; height: 116px">
</td>
</tr>
<script language="javascript" type="text/javascript">
function showDiv(divID)
{
var div_used = this.div_used;
var div_current = this.div_current;
if(divID== 'div_current')
{
div_current.style.display = "block";
div_used.style.display = "none";
}
else
{
div_used.style.display = "block";
div_current.style.display = "none";
}
}
</script>
</table>
</body>
</html>