本文介绍了jQueryUI - 手风琴 - 使用 ID 设置活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我检查了许多网站试图解决这个问题.但是,我运气不好,我想我会继续在这里发帖.

我想要做的是根据 ID 设置 Active Accordion.下面是我正在使用的内容.

jQuery 代码:

$(function () {$("#accordion").手风琴({可折叠:真实,标题:h3",活动:'h3.content3',高度样式:内容"});});

HTML:

<h3 class="content1">内容标题</h3><div align="left"><p>1 的内容在这里</p>

<h3 class="content2">内容标题</h3><div align="left"><p>2 人的内容在这里</p>

<h3 class="content3">内容标题</h3><div align="left"><p>3 人的内容在这里</p>

我希望我解释得足够好,如果没有,请告诉我.我会尽力帮助你.

解决方案

Set active 基于 h3 索引:

active: $('#accordion h3').index($('.content3'))

I've checked a number of sites trying to figure this out. However, I have had no luck and figured I would go ahead and make a post on here.

What I am trying to do is setting the Active Accordion depending on ID. Below, is what I am working with.

jQuery Code:

$(function () {
    $("#accordion").accordion({
        collapsible: true,
        header: "h3",
        active: 'h3.content3',
        heightStyle: "content"
    });
});

HTML:

<div id="accordion">
    <h3 class="content1">Content Title</h3>
    <div align="left">
        <p>Content for 1 Goes Here</p>
    </div>

    <h3 class="content2">Content Title</h3>
    <div align="left">
        <p>Content for 2 Goes Here</p>
    </div>

    <h3 class="content3">Content Title</h3>
    <div align="left">
        <p>Content for 3 Goes Here</p>
    </div>
</div>

I hope I explained it well enough, If not, Let me know. I'll try to help ya.

解决方案

Set active based on the h3 index:

active: $('#accordion h3').index($('.content3'))

这篇关于jQueryUI - 手风琴 - 使用 ID 设置活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 12:34