[英]jquery ui accordion expanding in one click but not collapsing in second click
i have accordion while clicking once its expanding (opening) but while i clicking again on that its not closing the accordion. 我有一次手风琴点击它的扩展(打开),但我再次点击它没有关闭手风琴。 how to change the function so that i can close the accordion when i click second time to the accordion.
如何更改功能,以便在我第二次单击手风琴时可以关闭手风琴。
$(function() { var icons = { header: "ui-icon-circle-arrow-e", activeHeader: "ui-icon-circle-arrow-s" }; $("#accordion").accordion({ icons: icons }); $("#toggle").button().on("click", function() { if ($("#accordion").accordion("option", "icons")) { $("#accordion").accordion("option", "icons", null); } else { $("#accordion").accordion("option", "icons", icons); } }); });
<section class="content"> <h1 style="color:#B94A7E"> header 1</h1> <div id="accordion"> <h3 style="font-size:16px">header 3</h3> <div> <table> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> <tr> <td> <font color="#5a5453"> 4. The actual IoT platform that builds, connects and manages includes all APIs, Web services, application services, agents, connectivity etc </font> </td> </tr> <tr> <td></td> </tr> <tr> <td> </td> </tr> <tr> <td> </td> </tr> </table> </div>
An accordion doesnot allow more than one content panel to be open at the same time.Read JQuery UI documentation for Accordion.Usually what you want to achieve can be written with few line of jquery code itself as below 手风琴不允许同时打开一个以上的内容面板。阅读有关手风琴的JQuery UI文档 。通常,您可以用几行jquery代码本身来编写要实现的目标,如下所示
$('#accordion').click(function() {
$(this).next().toggle('slow');
});
http://jsfiddle.net/g8yoqmsL pasted your code and fixed in fiddle. http://jsfiddle.net/g8yoqmsL粘贴了您的代码并固定在小提琴中。
$( "#accordion" ).accordion({
collapsible: true
});
Docs here http://jqueryui.com/accordion/#collapsible 此处的文档http://jqueryui.com/accordion/#collapsible
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.