手风琴/多个实例 - 仅打开一个

发布于 2024-10-04 18:55:52 字数 656 浏览 0 评论 0原文

我正在使用 ui 手风琴。

我在一页上有同一个手风琴的多个实例。

因为它是同一个手风琴的复制品, 其中的链接具有相同的 href 值, 所以每个手风琴都打开了... 但我只需要一台打开的手风琴,就是发出咔嗒声的那一台。

这可能吗? 有人可以帮我解决这个问题吗?

感谢你。

$('#nav ul li').accordion({ 
        active: 'a.current',
        header: '.head', 
        navigation: true, 
        event: 'click', 
        //fillSpace: true, 
        animated: 'easeslide',
        collapsible: true,
        autoHeight: false
    });




      $("#nav ul li").each(function () {
        var li = $(this);
        var a = li[0].firstChild;
        if (a.href == location.href) {
            $(a).addClass("current");
        }
    });

i am using ui accordion.

i have multiple instances of the same accordion on one page.

because it is the same accordion duplicated,
the links inside it have the same href value,
so every accordion is opened...
but I need only one OPENED accordion, the one were the click came from.

Is this possible?
Can someone help me with this?

thank u.

$('#nav ul li').accordion({ 
        active: 'a.current',
        header: '.head', 
        navigation: true, 
        event: 'click', 
        //fillSpace: true, 
        animated: 'easeslide',
        collapsible: true,
        autoHeight: false
    });




      $("#nav ul li").each(function () {
        var li = $(this);
        var a = li[0].firstChild;
        if (a.href == location.href) {
            $(a).addClass("current");
        }
    });

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

嘿咻 2024-10-11 18:55:52

你需要在你的 jquery 代码中实现一个(this),你可以发布你当前的代码,以便我们可以看到

我唯一能想到的是:

$('#nav ul li', this).accordion({ 
    active: 'a.current',
    header: '.head', 
    navigation: true, 
    event: 'click', 
    //fillSpace: true, 
    animated: 'easeslide',
    collapsible: true,
    autoHeight: false
});

You need to implement a (this) into your jquery code, can you post your current code so we can see

The only thing i can think of is this:

$('#nav ul li', this).accordion({ 
    active: 'a.current',
    header: '.head', 
    navigation: true, 
    event: 'click', 
    //fillSpace: true, 
    animated: 'easeslide',
    collapsible: true,
    autoHeight: false
});
不乱于心 2024-10-11 18:55:52

也许尝试这样的事情:

$(".ac-menu").accordion({
    "header": "a.menuitem"
})
.bind("accordionchangestart", function(e, data)
{
    data.newHeader.next().andSelf().addClass("current");
    data.oldHeader.next().andSelf().removeClass("current");
})
.find("a.menuitem:first").addClass("current")
.next().addClass("current");

Maybe try something like this:

$(".ac-menu").accordion({
    "header": "a.menuitem"
})
.bind("accordionchangestart", function(e, data)
{
    data.newHeader.next().andSelf().addClass("current");
    data.oldHeader.next().andSelf().removeClass("current");
})
.find("a.menuitem:first").addClass("current")
.next().addClass("current");
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文