2017-03-12 64 views
1

会有一种简单的方法来打开与基金会的手风琴锚?与锚定打开accordeon面板

我简单的代码(上codepen提供)

<a href="#panel1" class="link">Open the first panel</a> 
<a href="#panel2" class="link">Open the second panel</a> 


<ul class="accordion" data-accordion> 
    <li class="accordion-item" data-accordion-item> 
    <a href="#" class="accordion-title">Accordion 1</a> 
    <div class="accordion-content" data-tab-content> 
     I would start in the open state, due to using the `is-active` state class. 
    </div> 
    </li> 

    <li class="accordion-item" data-accordion-item> 
    <a href="#" class="accordion-title">Accordion 2</a> 
    <div class="accordion-content" data-tab-content> 
     I would start in the open state, due to using the `is-active` state class. 
    </div> 
    </li> 
</ul> 

我已通过基金会的文档了,但没有一个预先设计的系统不在话下。

有人可以帮助我使用这种系统吗?我承认我不知道该怎么做。

非常感谢。

回答

0

如果添加了jQuery UI库这个额外的代码会为你的工作,例如:

$(".accordion").accordion(); 
$('a').on('click',function() { 
    $('.accordion').accordion("option", "active", $(this).index()); 
}) 

CodePen:http://codepen.io/anon/pen/YZQxWd

个人而言,我将特定ID添加到手风琴和引用它使用它而不是手风琴类。另外,我会指定一个类来使用链接,而不是捕获所有链接,就像我在工作示例代码中所做的那样。