高分求助!!!菜单为何实现不了....

网页文件如下,请大侠指点一二,感谢不尽.

 1<html>
 2<head>
 3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 4<title>5</title>
 5<style type="text/css">   
 6.c1 {position: absolute;font-size:11pt;font-weight: bold;line-height: 14pt;color:#ff0000;font-family:宋体}   
 7.c2 {position: absolute;font-size:9pt;line-height:12pt;color:yellow;}   
 8.c3 {position: absolute;font-size:9pt;line-height:12pt;color:blue;}   
 9.d1 { position:absolute; left: 35px; display:none;width: 170px;font-size:9pt;line-height:12pt;color:blue;}   
10a:link {text-decoration: none;}   
11a:visited {text-decoration: none;color:#ff0000}   
12a:active {text-decoration: underline;}   
13a:hover {text-decoration: underline;}   
14</style>
15</head>
16<body>
17<script>   
18function hideAll() {   
19for(i=0;i<child.length;i++) {   
20child[i].style.display="none";   
21}   
22}   
23  
24function showObj(num) {   
25if (child[num].style.display=="none")   
26{   
27hideAll();   
28child[num].style.display="block";   
29}   
30else {   
31child[num].style.display="none";   
32}   
33}   
34</script>
35<table border="1">
36<tr>
37<td> <img border="0" height="16" id="img1" name="img1" src="new/close.gif" width="9"/>
38<a href="#" onclick="showObj(0)">111</a><br/>
39<div class="d1" id="child">
40<a href="9.htm" target="data">1111</a><br/>
41<a href="10.htm" target="data">1111</a><br/>
42<a href="11.htm" target="data">1111</a><br/>
43<a href="12.htm" target="data">11</a><br/>
44<a href="13.htm" target="data">11</a><br/>
45<a href="14.htm" target="data">11</a><br/>
46</div>
47</td>
48</tr>
49<tr>
50<td><img border="0" height="16" id="img1" name="img1" src="new/close.gif" width="9"/>
51<a href="#" onclick="showObj(1)">22</a><br/>
52<div class="d1" id="child">
53<a href="15.htm" target="data">22</a><br/>
54<a href="16.htm" target="data">22</a><br/>
55</div>
56</td></tr>
57<tr>
58<td>
59<img border="0" height="16" id="img1" name="img1" src="new/close.gif" width="9"/>
60<a href="#" onclick="showObj(2)">33</a><br/>
61<div class="d1" id="child">
62<a href="15.htm" target="data">33</a><br/>
63</div>
64</td></tr>
65<tr><td>
66<img border="0" height="16" id="img1" name="img1" src="new/close.gif" width="9"/>
67<a href="#" onclick="showObj(3)">44</a><br/>
68<div class="d1" id="child">
69<a href="9.htm" target="data">44</a><br/>
70<a href="10.htm" target="data">44</a><br/>
71<a href="11.htm" target="data">44</a><br/>
72</div>
73</td></tr>
74<tr><td>
75<img border="0" height="16" id="img1" name="img1" src="new/close.gif" width="9"/>
76<a href="#" onclick="showObj(4)">55</a><br/>
77<div class="d1" id="child">
78<a href="21.htm" target="data">55</a><br/>
79<a href="22.htm" target="data">55</a><br/>
80<a href="23.htm" target="data">55</a><br/>
81<a href="24.htm" target="data">55</a>
82</div>
83</td></tr>
84<tr><td>
85<img border="0" height="16" id="img1" name="img1" src="new/close.gif" width="9"/>
86<a href="#" onclick="showObj(5)">66</a><br/>
87<div class="d1" id="child">
88<a href="25.htm" target="data">66</a><br/>
89</div>
90</td></tr>
91</table>
92</body>
93</html>

---------------------------------------------------------------

很明显的错误id重复了,改为name,引用时var cld=document.getElementsByName("child")

Published At
Categories with Web编程
Tagged with
comments powered by Disqus