Bomski Bomski - 2 years ago 83
Javascript Question

jQuery Accordion - open specific section on pageload

I have a rather basic implementation of a jQuery Accordion on a page (using 1.3.2, jQuery UI Core 1.72 and jQuery UI Accordion 1.7.2), and I wish to open the 2nd section when the page loads. i've tried numerous methods but nothing seems to work...


<script type="text/javascript"> $(function() {
event: "mouseover"



<div id="accordion">
<h3><a href="#">Headline 001</a></h3>
<li><a href="#1">Link 001</a></li>
<li><a href="#2">Link 002</a></li>
<h3><a href="#">Headline 002</a></h3>
<li><a href="#3">Link 003</a></li>
<li><a href="#4">Link 004</a></li>

Any help would be greatly appreciated!

Answer Source
$("#accordion").accordion({ active: 2, event: "mouseover" });

Should do the trick!


if that doesn't work, try

$("#accordion").accordion({  event: "mouseover" }).activate(2);

(N.B. this is updated to be a bit faster, thanks for the comments. To be honest, it should work with the 'active: 2' parameter, don't know why it didn't.)

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download