<div class="codetitle"> <span><a style="CURSOR: pointer" data="6647" class="copybut" id="copybut6647" onclick="doCopy('code6647')"><u>複製程式碼</u></a></span> 程式碼如下:</div> <div class="codebody" id="code6647"> <br>pageEncoding="UTF-8"%> <br> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=UTF-8 "> <br><title>jqueryMenu</title> <br><script type="text/javascript" src="js/jquery-1.10.2.js"></script> <br><script type="text/javascript"> <BR>$(document).ready(function(){ <BR>var allMenu=$("ul > a");//找到所有主選單<BR>allMenu.click(function( ){ <BR>var list=$(this).nextAll('li');//找到所有目前被點擊a節點的li兄弟節點<BR>list.toggle('show'); <BR>}) ; <BR>}); <BR></script> <br> <br> <br><ul> <a href="#">選單一</a> <br> <li><a href="#">子選單一</a></li> <br><li><a href="#">子選單二</a></li> <br> </ul> <br><ul> <a href="#">選單二</a> <br><li><a href="#">子選單一</a></li> <br><li><a href="#">子選單二</a></li> <br> </ul> <br> <br> <br> </div>