我只想要一个简单的切换 js,所以当您在导航中单击 About 时,会出现 about 文本,但它现在可以正常工作了
JS部分:
<script language="JavaScript" type="text/javascript">
function toggle() {
var about = document.getElementById('about')
if(about.style.display = "none")
{
about.style.display = "block";
}
else
{
about.style.display = "none";
}
}
</script>
HTML:
<header>
...
<nav><ul>
<li><a href="index.html" id="active">Home</a></li>
<li><a href="javascript:toggle()" onClick="toggle()">About me</a></li>
...more <li>s...
</ul></nav>
</header>
<br/>
<div id="about">
aboutme
</div>
CSS:
#about {
display: none;
}
我究竟做错了什么??有谁能够帮助我?