2009-08-29 190 views

回答

1

jQuery Accordion這樣做。

您可以使用此代碼(從jQuery手風琴頁)嘗試一下:

頭:

<script type="text/javascript" src="http://jqueryui.com/latest/jquery-1.3.2.js"></script> 
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.core.js"></script> 
<script type="text/javascript" src="http://jqueryui.com/latest/ui/ui.accordion.js"></script> 
<script type="text/javascript"> 
$(document).ready(function(){ 
$("#accordion").accordion(); 
}); 
</script> 

身體:

<div id="accordion"> 
    <h3><a href="#">Section 1</a></h3> 
    <div>Mauris mauris ante</div> 
    <h3><a href="#">Section 2</a></h3> 
    <div>Sed non urna</div> 
    <h3><a href="#">Section 3</a></h3> 
    <div>Nam enim risus </div> 
    <h3><a href="#">Section 4</a></h3> 
    <div>Cras dictum</div> 
</div> 
1

使用jQuery,我有這樣的腳本我使用:

$(document).ready(function() { 
    $(".nav > li > a").click(function() { 
     $("ul", $(this).parent()).slideToggle("normal"); 
     return false; 
    }); 
    $(".nav ul").hide(); // Hide all on load. Done here rather than in CSS so users 
    // see the menu if they have javascript disabled. 
}); 

菜單在HTML中標記爲:

<ul class="nav"> 
    <li><a href="#">Header</a></li> 
    <li> 
      <ul> 
       <li>Sub list Items</li> 
       <!-- More --> 
      </ul> 
    </li> 
</ul> 

對於每個可展開部分。