1
我想要有一個可摺疊的元素列表,其中只有一個可以在任何給定時間看到。JQuery手風琴風格列表
我把它像:
<div class="grid_12" id="menu_container">
<div class="grid_12 title" style="background-color:pink;">
Book 1
</div>
<div class="grid_12 row" style="background-color:white;">
Chapter 1
<div class="grid_12 details">Lorem lipsum sin dolor chapter 1</div>
</div>
<div class="grid_12 row" style="background-color:white;">
Chapter 2
<div class="grid_12 details">Lorem lipsum sin dolor chapter 2</div>
</div>
</div>
我嘗試了很多的東西與我的javascript函數,並結束了失落和迷惘...... 任何人都可以請幫我在這?
$(".row").click(function(e){
$(".current").slideUp(function(){
$(".current").hide();
$(".current").removeClass("current");
});
$(this).children("div.details").addClass("current");
$(this).children("div.details").slideDown();
});
在此先感謝! S.
是否有一個理由,爲什麼你不使用jQueryUI的手風琴功能?不值得重新發明輪子:) http://jqueryui.com/accordion/ – king14nyr
是的......我試圖瞭解如何在沒有使用手風琴的情況下做到這一點,但我一路上迷路了...... –