jquery - How to tell which Tab is currently open? Wet-Boew plugin -


i using tabbed interface wet-boews toolkit (http://wet-boew.github.io/v4.0-ci/docs/ref/tabs/tabs-en.html)

after page has loaded, how can determine tab open.

i have tried below strangely return true

     <div class="wb-tabs">          <div class="tabpanels">                 <details id="details-panel-panel1">                 <summary>example 1</summary>                  <p>                 ...             </p>                  </details>          <details id="details-panel-panel2">                <summary>example 2</summary>                 <p>              ...             </p>              </details>        </div>  </div>   var panel1 = ($("details-panel-panel1").attr("open")) ? true : false; var panel2 = ($("details-panel-panel2").attr("open")) ? true : false; 

two tips:

  • to element id need add # character before id $('#details-panel-panel1')

  • $("#details-panel-panel1").attr("open") value of attribute open, won't tell if exist (won't boolean).

said that, couldn't find in documentation, looking @ generated code, , cannot tell if tab open looking @ open attribute. notice 2 things:

  • the attribute aria-expanded true on open tab, , false on rest.
  • the open tab has class in, others have out.

you can go either way:

$('#details-panel10').attr('aria-expanded') === "true" 

or

$('#details-panel10').hasclass('in') === true 

Comments

Popular posts from this blog

ZeroMQ on Windows, with Qt Creator -

unity3d - Unity SceneManager.LoadScene quits application -

python - Error while using APScheduler: 'NoneType' object has no attribute 'now' -