日期:2014-05-16  浏览次数:20390 次

点击收缩表格某行,这到底错在哪里?简直疯了.
在一个表格中,我想实现点击一行,然后另一行隐藏起来,我写在以下代码,可是老是报:缺少对象!搞了一个晚上了,快搞疯了,高手们帮忙看看.javascript没有调试器,人什么时候疯了都不知道.

在 <head> 加入:
<script   language= "Javascript ">
function   CLICK(did)
            {
            var   dv=document.getElementById(did);
            if(dv.style.display== 'none '){dv.style.display= 'block ';}
              else   {dv.style.display= 'none ';}
            }
</script>

在body中加入以下:
<table   class= 'lefttable '>
                                <tr   class= 'firstbar '>
<td   class= 'firstbar '   background= "log/firstbar.png "   onclick= "CLICK(weather) "> Weather </td>
                                      </tr>
                                      <tr   id= "weather ">
<td>
                              <iframe   style= "WIDTH:   200px;   HEIGHT:   68px "   border= "0 "   marginWidth= "0 "   src= "http://weather.265.com/weather.htm "   frameBorder= "no "   width= "168 "   scrolling= "no "   height= "54 "   allowTransparency> </iframe>
                                  </td>
                          </tr>
</table>

------解决方案--------------------
老大,你这个weather要用引号引起,不然是个变量名,你没有这个变量撒
------解决方案--------------------
<html>
<head>
<title> adfjakdfjkal </title>
<script language= "Javascript ">

function CLICK(did)
{
var dv=document.getElementById(did);
if(dv.style.display== 'none ')
{dv.style.display= 'block ';}
else
{dv.style.display= 'none ';}
}
</script>
</head>
<body>
<table class= 'lefttable '>
<tr class= 'firstbar ' style= "cursor:hand ">
<td class= 'firstbar ' background= "log/firstbar.png " onclick= "CLICK( 'weather ') "> Weather </td>
</tr>
<tr id= "weather ">
<td>
<iframe style= "WIDTH: 200px; HEIGHT: 68px " border= "0 " marginWidth= "0 " src= "http://weather.265.com/weather.htm " frameBorder= "no " width= "168 " scrolling= "no " height= "54 " allowTransparency> </iframe>
</td>
<tr>
</table>
</body>
</html>