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...
HEAD SCRIPT:
<script type="text/javascript"> $(function() {
$("#accordion").accordion({
event: "mouseover"
});
});
BODY ACCORDION:
<div id="accordion">
<h3><a href="#">Headline 001</a></h3>
<div>
<ul>
<li><a href="#1">Link 001</a></li>
<li><a href="#2">Link 002</a></li>
</ul>
</div>
<h3><a href="#">Headline 002</a></h3>
<div>
<ul>
<li><a href="#3">Link 003</a></li>
<li><a href="#4">Link 004</a></li>
</ul>
</div>
Any help would be greatly appreciated!
Does the following work?
proper way to open a specific tab:
Set the option:
or you could work with a hash like this:
Vote if you use ;)
Thanks
You should write
active: 1
instead of 2, because Accordion indexes sections from 0, not from one. Working code will look like that:Hope it will help a bit.
I have resolved this question a little different since I had to create a menu.php which we include I have included every single page. In our project there was 1 accordion (a menu element with 2 submenus). So when the visitor is on the submenus, the accordion is open and the selected link (which are highlighted using CSS, not jQuery) active. But when the visitor is on a different page, the accordion works normally.
Here's the javascript:
Hope you like it. =]
Best regards! =]
As others have mentioned, the following will make it active on opening:
It is
active:1
since it is the 2nd of the accordion's index{0,1,2,...};
There seems to be some confusion in other answers as the element's contents contain the character "2
"...Should do the trick!
UPDATE
if that doesn't work, try
(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.)