这是我在进行展开/折叠时的以下代码,但我只是想在我进行扩展/折叠操作时识别索引。
请你给我一些示例代码。
$("#accordionDemo2").accordion({
collapsible: true
});
<p><h2>Hi, This is Multiple Panel Demo1</h2></p>
<div id="accordionDemo2">
<h3><a href="#" class="acc">Section 1</a></h3>
<div>
<p>Hi, This is Section 1</p>
</div>
<h3><a href="#" class="acc">Section 2</a></h3>
<div>
<p>Hi, This is Section 2</p>
</div>
<h3><a href="#" class="acc">Section 3</a></h3>
<div>
<p>Hi, This is Section 3</p>
</div>
<h3><a href="#" class="acc">Section 4</a></h3>
<div>
<p>Hi, This is Section 4</p>
</div>
</div>
答案 0 :(得分:0)
http://docs.jquery.com/UI/Accordion#option-active
活动元素的选择器。设置为false以在开始时不显示任何内容。需要折叠:是的。
//getter
var active = $( ".selector" ).accordion( "option", "active" );
//setter
$( ".selector" ).accordion( "option", "active", 2 );