2015-02-17 122 views
0

如何在手風琴開始時打開多個標籤?像這樣jQuery UI手風琴在開始時打開多個標籤

$(".selector").accordion("option", "active", 2); 
$(".selector").accordion("option", "active", 3); 

或這樣嗎?

$("#accordion").accordion({ 
    active: 1 
    active: 2 
}); 
+1

工作例如你可以在這裏找到一個提示[jQuery UI的手風琴,保持多個部分開放?](http://stackoverflow.com/questions/3479447/jquery-ui-accordion-that-keeps-multiple -sections開) – Spokey 2015-02-17 22:15:51

回答

0
You can use multiAccordion and it goes like this: 
    // this will make the second tab by default opened (index starts from 0) 
    $('.selector').multiAccordion({active: 1 }); 

    // [ OR ] 
    // supports multiple tabs to be opened by default 
    $('.selector').multiAccordion({active: [1, 2, 3] }); 

    // you can also set active:false if you don't want any tab to be opened by default 
    $('.selector').multiAccordion({active: false }); 

    // show all tabs 
    $('.selector').multiAccordion({active: 'all' }); 

    // hide all tabs 
    $('.selector').multiAccordion({active: 'none' }); 

    // you can set the options as any jQuery UI plugin using option method 
    $('.selector').multiAccordion('option', 'active', 'all'); 
0

試試這個,

JS

$("#accordion > div").accordion({ header: "h2", collapsible: true }); 

HTML

<div id="accordion"> 
    <div> 
     <h2><a href="#">First</a></h2> 
     <div>First Secton of hello world.</div> 
    </div> 
    <div> 
     <h2><a href="#">Second</a></h2> 
     <div>Second Secton of hello world.</div> 
    </div> 
    <div> 
     <h2><a href="#">Third</a></h2> 
     <div>Third Secton of hello world.</div> 
    </div> 
    <div> 
     <h2><a href="#">Fourth</a></h2> 
     <div>Forth Secton of hello world.</div> 
    </div> 
</div> 

fiddle