动态Jquery手风琴

时间:2010-03-31 20:21:48

标签: javascript jquery jquery-plugins javascript-events jquery-effects

如何在启动时默认关闭手风琴。这是示例视图here

以下是代码:

<script>
$(function() { 

$("#accordion").tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide'});
});
</script>

<script>

// add new effect to the tabs
$.tools.tabs.addEffect("slide", function(i, done) {

    // 1. upon hiding, the active pane has a ruby background color
    this.getPanes().slideUp("slow").css({backgroundColor: "#fff"});

    // 2. after a pane is revealed, its background is set to its original color (transparent)
    this.getPanes().eq(i).slideDown("slow", function()  {
        $(this).css({backgroundColor: 'transparent'});

        // the supplied callback must be called after the effect has finished its job
        done.call();
    });
});
</script>

2 个答案:

答案 0 :(得分:0)

加入你的CSS:

#accordion div.pane: display:none;

答案 1 :(得分:0)

你可以这样做:

$("#accordion")
  .tabs("#accordion div.pane", {tabs: 'h3', effect: 'slide', collapsible: true})
  .tabs('select', false);

这会将其标记为collapsible,然后使用false选择无法显示的标签。