如何在展开/折叠所有函数中排除嵌套的手风琴

时间:2015-06-22 19:11:19

标签: javascript jquery-ui-accordion

我需要使用以下代码折叠/展开根密码为#accordion1。 但与此同时,我必须忽略/排除嵌套的accrodion为#nestedAccordion

我无法正常工作。请帮忙。

function ExpandAll() {
        $('.ui-accordion-header').not('#nestedAccordion').removeClass('ui-corner-all').addClass('ui-accordion-header-active ui-state-active ui-corner-top').attr({ 'aria-selected': 'true', 'tabindex': '0' });
        $('.ui-accordion-header .ui-icon').not('#nestedAccordion').removeClass('ui-icon-triangle-1-e').addClass('ui-icon-triangle-1-s');
        $('.ui-accordion-content').not('#nestedAccordion').addClass('ui-accordion-content-active').attr({ 'aria-expanded': 'true', 'aria-hidden': 'false' }).show();
    }

    function CollapseAll() {
        $('.ui-accordion-header').not('#nestedAccordion').removeClass('ui-accordion-header-active ui-state-active ui-corner-top').addClass('ui-corner-all').attr({ 'aria-selected': 'false', 'tabindex': '-1' });
        $('.ui-accordion-header .ui-icon').not('#nestedAccordion').removeClass('ui-icon-triangle-1-s').addClass('ui-icon-triangle-1-e');
        $('.ui-accordion-content').not('#nestedAccordion').removeClass('ui-accordion-content-active').attr({ 'aria-expanded': 'false', 'aria-hidden': 'true' }).hide();
    }

HTML

<div id="accordion1">
  <h3>Section 1</h3>
  <div>
   <div id="nestedAccordion">
    <h3>Section A</h3>
    <div>
       Text... 
    </div>
    <h3>Section B</h3>
    <div>
       Text... 
    </div>
   </div>     
  </div>
  <h3>Section 2</h3>
  <div>    
    Text...       
  </div>
</div>

0 个答案:

没有答案