jQuery:隐藏“活动类”当鼠标未悬停时

发布于 2024-12-25 20:36:04 字数 706 浏览 1 评论 0原文

我有以下 jQuery 插件: http://jqueryfordesigners.com/slide-out-and -drawer-effect/

现在的问题是:当鼠标不在元素上方时,我想关闭活动的“抽屉”。 jQuery 设置为保持活动元素打开,直到鼠标悬停应用于另一个抽屉元素。当鼠标悬停在任何一个抽屉上时,如何关闭所有抽屉?

初始化代码:

$(function () {
    $('UL.drawers').accordion({
        // the drawer handle
        header: 'H2.drawer-handle',

        // our selected class
        selectedClass: 'open',

        // match the Apple slide out effect
        event: 'mouseover'
    });
});

此外,当我将“open”类应用于抽屉元素 css (.drawer-handle.open {}) 时,活动抽屉手柄不会改变颜色(动画),因为它应该。这是为什么?我在 Joomla 1.7 中使用 PHP

谢谢!

I have the following jQuery plugin: http://jqueryfordesigners.com/slide-out-and-drawer-effect/

Now the problem is: I would like to close the active 'drawer' when the mouse is not over the element. The jQuery is set to keep the active one open until the mouseover is applied to another drawer element. How do I close all the drawers when not hovering over any of them?

Initialization code:

$(function () {
    $('UL.drawers').accordion({
        // the drawer handle
        header: 'H2.drawer-handle',

        // our selected class
        selectedClass: 'open',

        // match the Apple slide out effect
        event: 'mouseover'
    });
});

Also, when I apply the 'open' class to the drawer element css (.drawer-handle.open {}), the active drawer-handle does not change color(animate) as it should. Why is that? I'm using PHP within Joomla 1.7

Thanks!

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

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

发布评论

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

评论(1

风吹雪碎 2025-01-01 20:36:04

这是为您提供的部分解决方案:

$(function() {
    var $accordian = $('UL.drawers').accordion({
        // the drawer handle
        header: 'H2.drawer-handle',

        // our selected class
        selectedClass: 'open',

        // match the Apple slide out effect
        event: 'mouseover',

        // allow all drawers to be closed (default is "true" - always keep a draw open)
        alwaysOpen: false
    }).activate(false);

    $('UL.drawers').mouseout(function () {
        // close all the drawers when the mouse leaves the parent list
        $accordian.activate(false);
    });
});

我说部分是因为此设置的行为并不像我想象的那么顺利,但如果结果接近您正在寻找的结果,那么它应该会让您朝着正确的方向开始。

您可以使用以下 jsFiddle 来查看它的运行情况: http://jsfiddle.net/gKNGh/1/

Here is a partial solution for you:

$(function() {
    var $accordian = $('UL.drawers').accordion({
        // the drawer handle
        header: 'H2.drawer-handle',

        // our selected class
        selectedClass: 'open',

        // match the Apple slide out effect
        event: 'mouseover',

        // allow all drawers to be closed (default is "true" - always keep a draw open)
        alwaysOpen: false
    }).activate(false);

    $('UL.drawers').mouseout(function () {
        // close all the drawers when the mouse leaves the parent list
        $accordian.activate(false);
    });
});

I say partial because the behavior of this setup is not quite as smooth as I think it should be, but if the result is close to what you are looking for it should get you started in the right direction.

You can see it in action with this jsFiddle: http://jsfiddle.net/gKNGh/1/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文