问题
jQuery UI's Accordion widget has the active option to keep a certain panel open, but I'm trying to find a way to do this dynamically.
In other words, I want to have a panel open when it corresponds with the page.
HTML:
<ul id="nav-side" class="accordion">
<li class="accordion-title"><a href="#">RPO</a>
<ul>
<li><a href="/services/direct/rpo/index.php">Value</a></li>
<li><a href="/services/direct/rpo/solution-competencies.php">Solution Competencies</a></li>
<li><a href="/services/direct/rpo/rpo-models.php">Defined RPO Models</a></li>
<li><a href="/services/direct/rpo/program-management.php">Dedicated Program Management</a></li>
<li><a href="/services/direct/rpo/solution-planning.php">Solution Planning & Implementation</a></li>
</ul>
</li>
<li class="accordion-title"><a href="#">CONSULTING</a>
<ul>
<li><a href="/services/direct/consulting/index.php">#</a></li>
<li><a href="#">#</a></li>
<li><a href="#">#</a></li>
</ul>
</li>
<li class="accordion-title"><a href="#">CRM</a>
<ul>
<li><a href="#">#</a></li>
<li><a href="#">#</a></li>
<li><a href="#">#</a></li>
</ul>
</li>
</ul>
So if the user is in the RPO section, the first panel would be open. If in the Consulting section, the second panel would be open.
来源:https://stackoverflow.com/questions/23817904/jquery-ui-accordion-keep-panel-open-according-to-page