Jquery手风琴在另一支手风琴上打开

时间:2015-06-05 09:34:36

标签: javascript jquery html jquery-ui

我有四个手风琴,如下面的代码,当我关闭手风琴时,BackupCoWorker4会自动地使用手风琴,BackupCoWorker2应该打开,让其他所有东西都关闭。请看下面这个小提琴。提前谢谢。



$("#BackupCoAcc1").accordion({
  collapsible: true,
  active: false,
  heightStyle: "content"
});
$("#BackupCoAcc2").accordion({
  collapsible: true,
  active: false,
  heightStyle: "content"
});
$("#BackupCoAcc3").accordion({
  collapsible: true,
  active: false,
  heightStyle: "content"
});
$("#BackupCoAcc4").accordion({
  collapsible: true,
  active: false,
  heightStyle: "content"
});

<body>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.11.4/jquery-ui.js"></script>

  <div id="BackupCoAcc1" class="accordion">
    <h3>Backup CoWorker1(s)</h3>
    <div id="BackupDiv1"> Jobs for:<span id="bckupWorkers1">&nbsp;Me</span>
    </div>
  </div>
  <div id="BackupCoAcc2" class="accordion">
    <h3>Backup CoWorker2(s)</h3>
    <div id="BackupDiv2"> Jobs for:<span id="bckupWorkers2">&nbsp;Me</span>
    </div>
  </div>
  <div id="BackupCoAcc4" class="accordion">
    <h3>Backup CoWorker4(s)</h3>
    <div id="BackupDiv4"> Jobs for:<span id="bckupWorkers4">&nbsp;Me</span>
    </div>
  </div>
  <div id="BackupCoAcc3" class="accordion">
    <h3>Backup CoWorker3(s)</h3>
    <div id="BackupDiv3"> Jobs for:<span id="bckupWorkers3">&nbsp;Me</span>
    </div>
  </div>
</body>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

  

它为我工作

$(&#34;#BackupCoAcc4&#34)上(&#34;单击&#34;,函数(E){          $(&#34;#BackupCoAcc1&#34)手风琴({。              活性:0          });      });