Javascript显示和隐藏ul列表
<ul id="rightNav"> <li> <h2 class="rightNavItem"><a href="#">Show & Hide</a></h2> <ul> <li><a href="">Links etc here</a></li> </ul> </li> </ul> <script> function enableRightNavExpand() { if (!document.getElementById) return false; if (!document.getElementById("rightNav")) return false; var nav = document.getElementById("rightNav"); var navItem = nav.getElementsByTagName("li"); for (var i = 0; i < navItem.length; i++){ navItem[i].onclick=function() { if (this.className == "selected") { this.className = ""; } else if (this.className == ""){ this.className = "selected"; } } } } </script>