用JavaScript创建可折叠导航菜单

<html>
<head>
<script type="text/javascript">
function collapse(zap){
	if(document.getElementById){
	    var abra=document.getElementById(zap).style;
		if(abra.display=="block"){
	        abra.display="none";
	    }else{
			abra.display="block";
	    }
	 return false;
	 }else{
		return true;
	 }
}
</script>
</head>
<body>
<h5><a onclick="return collapse('link');" href="#">Links</a></h5>
<ul id="link">
<li><a href="#">Link One</a></li>
<li><a href="#">Link Two</a></li>
<li><a href="#">Link Three</a></li>
<li><a href="#">Link Four</a></li>
</ul>
</body>
</html>

你可能感兴趣的:(JavaScript)