jQuery UI Accordion Can't Open 3rd Panel Programatically
Having trouble getting the 3rd panel in a Jquery UI Accordion to open via a jQuery program call, while keeping panels 1 and 2 closed. My HTML structure is like this:
<div class="accordion1">
<div class="left-menu-title" id="restaurant">
<h3>Restaurant</h3>
</div>
<div class="left-menu clickable" id="nav-restaurant">
<div id="cat_581274_divs">
<ul id="nav_581274">
<li><a href="/reservations">reservations</a></li>
<li><a href="/menus">menus</a></li>
</ul>
</div>
</div>
<div class="left-menu-title" id="bakery">
<h3>Bakery</h3>
</div开发者_如何学运维>
<div class="left-menu clickable" id="nav-bakery">
<div id="cat_581276_divs">
<ul id="nav_581276">
<li><a href="/pastry-chef">our pastry chef</a></li>
<li><a href="/bakery-menu">bakery menu</a></li>
</ul>
</div>
</div>
<div class="left-menu-title" id="wine">
<h3>Wine Shop</h3>
</div>
<div class="left-menu clickable" id="nav-wine">
<div id="cat_581280_divs">
<ul id="nav_581280">
<li><a href="/wine-shop">about our wine shop</a></li>
<li><a href="/wine-tastings">wine tastings & events</a></li>
</ul>
</div>
</div>
My accordian is initialized with:
$(".accordion1").accordion({ header: ".left-menu-title" });
and it works great. I am trying to programatically open the 3rd #wine Wine Shop panel with the Restaurant and Bakery panels closed, but when I use any of these ALL the panels open instead of just the 3rd:
$('.accordion1').accordion('activate', 2 );
doesn't work nor does
$('.accordion1').accordion('activate', 'div#wine');
nor does
$('.accordion1').accordion('activate', 'div#wine h3');
nor does
$('.accordion1').accordion('activate', '#nav-wine');
Obviously doing something wrong. Using jquery-ui-1.8.5.custom.min.js and jquery/1.4.2/jquery.min.js
Run them in order, like so:
$(".accordion1").accordion({ header: ".left-menu-title" });
$('.accordion1').accordion('activate', 2 );
See it in action: http://jsfiddle.net/WWPFq/
精彩评论