从现有的小提琴开始,我创建了这个示例:http: //jsfiddle.net/2DaR6/90/
这是html代码:
<div id="accordion">
<h3 id="header1" class="accClicked"><a href="#">Section 1</a></h3>
<div> Good Morning Stackoverflow</div>
<h3 id="header2" class="accClicked"><a href="#">Section 2</a></h3>
<div>Buongiorno Stackoverflow</div>
<h3 id="header3" class="accClicked"><a href="#">Section 3</a></h3>
<div>Bonjour Stackoverflow</div>
</div>
这是js代码:
$(function() {
var icons = {
header: "ui-icon-circle-arrow-e",
headerSelected: "ui-icon-circle-arrow-s"
};
$( "#accordion" ).accordion({
icons: icons,
collapsible: true
});
$( "#header1" ).click(function() {
$( "#accordion" ).accordion( "option", "icons", false );
}, function() {
$( "#accordion" ).accordion( "option", "icons", icons );
});
});
如果我单击第 1 节,手风琴正确打开,但我希望单击其他项目,以前打开的项目不会关闭。我怎样才能获得这种行为?谢谢