html 网页里点击一下显示出下拉内容,上一次点击内容自动收回,代码怎么写?在线等,谢谢!
<!DOCTYPEHTMLPUBLIC"-//W3C//DTDHTML4.0Transitional//EN"><HTML><HEAD><SCRIPT>functioni...
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<SCRIPT>
function isHidden(oDiv){
var vDiv = document.getElementById(oDiv);
vDiv.style.display = (vDiv.style.display == 'none')?'block':'none';
}
</SCRIPT>
</HEAD>
<BODY>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div1')"><font color="#0072E3"><strong>1.READ MORE</strong> </td>
<div id="div1" class="zt" style="display:none"><strong>javascript + CSS</div></br>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div2')"><font color="#0072E3"><strong>2.READ MORE</strong> </td>
<div id="div2" class="zt" style="display:none"><strong>javascript + CSS</strong></div></br>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div3')"><font color="#0072E3"><strong>3.READ MORE</strong> </td>
<div id="div3" class="zt" style="display:none"><strong>javascript + CSS</strong></div></br>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div4')"><font color="#0072E3"><strong>4.READ MORE</strong> </td>
<div id="div4" class="zt" style="display:none"><strong>javascript + CSS</strong> </div></br>
</BODY>
</HTML> 展开
<HTML>
<HEAD>
<SCRIPT>
function isHidden(oDiv){
var vDiv = document.getElementById(oDiv);
vDiv.style.display = (vDiv.style.display == 'none')?'block':'none';
}
</SCRIPT>
</HEAD>
<BODY>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div1')"><font color="#0072E3"><strong>1.READ MORE</strong> </td>
<div id="div1" class="zt" style="display:none"><strong>javascript + CSS</div></br>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div2')"><font color="#0072E3"><strong>2.READ MORE</strong> </td>
<div id="div2" class="zt" style="display:none"><strong>javascript + CSS</strong></div></br>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div3')"><font color="#0072E3"><strong>3.READ MORE</strong> </td>
<div id="div3" class="zt" style="display:none"><strong>javascript + CSS</strong></div></br>
<td colspan="2" height="15"align="left"class="STYLE6" ><a href= style="cursor:hand" style="text-decoration:none" onclick="isHidden('div4')"><font color="#0072E3"><strong>4.READ MORE</strong> </td>
<div id="div4" class="zt" style="display:none"><strong>javascript + CSS</strong> </div></br>
</BODY>
</HTML> 展开
2个回答
2014-08-21
展开全部
你写的标签太乱了。
td必须要有table,tr标签一起,不能单独写td,浏览器会识别错乱的。js也会很难获取该标签
标签必须要要闭合,你的a标签,font标签都只有开始,没有结束
用js库,别用源生js了来写效果,容易上手:
展开全部
function isHidden(oDiv){
var a = ['div1','div2','div3','div4'];
for (var i=0;i<a.length;i++)
{
if(oDiv==a[i])
{
var vDiv = document.getElementById(a[i]);
vDiv.style.display = 'block';
}
else
{
var vDiv = document.getElementById(a[i]);
vDiv.style.display = 'none';
}
}
//vDiv.style.display = (vDiv.style.display == 'none')?'block':'none';
}
var a = ['div1','div2','div3','div4'];
for (var i=0;i<a.length;i++)
{
if(oDiv==a[i])
{
var vDiv = document.getElementById(a[i]);
vDiv.style.display = 'block';
}
else
{
var vDiv = document.getElementById(a[i]);
vDiv.style.display = 'none';
}
}
//vDiv.style.display = (vDiv.style.display == 'none')?'block':'none';
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询