首頁 >web前端 >js教程 >JavaScript製作的可折疊彈出式選單範例_javascript技巧

JavaScript製作的可折疊彈出式選單範例_javascript技巧

WBOY
WBOY原創
2016-05-16 16:53:161297瀏覽
複製代碼如下代碼:

渡//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


>
可折疊下拉式選單 <br>頭> <br> <br>body {background-color: #FFF;color: #000;} <br>div {margin-bottom: 10px;} <br>ul .menu {display: none;list-style-type: none;margin -top:5px;} <br>a.menuLink {font-size:16px;font-weight:bold;} <br>; <br> <br>window.onload = initAll; <br>function initAll() { <br>var allLinks = document.getElementsByTagName("a"); <br>for ( var i=0; i<alllinks.length i>if (allLinks[i].className.indexOf("menuLink") > -1) { <br>allLinks[i] .onclick = 切換選單; <br>} <br>} <br>} <br>} <br>} <br>} <br>functiontoggleMenu() { <br>var startMenu = this.href.lastIndexOf("/") 1; <br>var stopMenu = this.Of.last" ."); <br>var thisMenuName = this.href.substring(startMenu,stopMenu); <br>var thisMenu = this.href.substring(startMenu,stopMenu); <br>var thisMenu = thisument.getElementById(thisMenuName).style; <br>if (docMenu.display == "block") { <br>thisMenu.display = "none"; <br>} <br>else { <br>thisMenu.display = "block"; <br>} <br>回傳false; <br>} <br> <br> <br><h1>莎士比亞戲劇</h1> <br><div>; <br><a href="menu1.html" class="menuLink">Comdeis</a> <br><ul class="menu" id="menu1"> <br><li><a href="pg1.html">一切順利,結局好</a></li> <br><a href="pg2.html">如您所願</a> <br><li> <a href="pg3.html">愛的勞動失去了</a> <br> </li> <li><a href="pg4.html">錯誤的喜劇</a></li> <br> </ul> <br> </div> <br><div> ; <br><a href="menu2.html" class="menuLink">悲劇</a> <br><ul class="menu" id="menu2"> <br><li><a href="pg5.html">安東尼與克莉奧佩特拉</a></li> <br><li><a href="pg6.html">哈姆雷特</a></li> <br><a href="pg7.html">羅密歐與茱麗葉</a> <br> </ul> <br> </div> <br><div>; <br><a href="menu3.html" class="menuLink">歷史記錄</a> <br><ul class="menu" id="menu3"> <br><li><a href="pg8.html">亨利四世,第1 部分</a></li> <br><li><a href="pg9.html">亨利四世,第二部分</a></li> <br> </ul> </div></alllinks.length>
身體>
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn