jQuery手风琴-在页面加载中打开特定部分 [英] jQuery Accordion - open specific section on pageload

查看:42
本文介绍了jQuery手风琴-在页面加载中打开特定部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页面上有一个相当基本的jQuery手风琴实现(使用1.3.2,jQuery UI Core 1.72和jQuery UI Accordion 1.7.2),我希望在页面加载时打开第二部分.我尝试了许多方法,但似乎无济于事...

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() {
    $("#accordion").accordion({
        event: "mouseover"
    });

});

手风琴:

<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>

任何帮助将不胜感激!

推荐答案

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

应该做到这一点!

更新

如果这不起作用,请尝试

if that doesn't work, try

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

(N.B.的更新速度更快,感谢您的评论.老实说,它应该与"active: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.)

这篇关于jQuery手风琴-在页面加载中打开特定部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆