切换两个面板,只有一个可见,这可能吗?

发布于 2024-09-17 00:38:28 字数 505 浏览 0 评论 0原文

我有两个滑动面板。我一次只需要打开一个面板。现在他们都可以打开。我的项目链接是: 链接文本

这是我的代码:

    $(document).ready(function(){
$(".btn-slide").click(function(){
    $("#panel_quote").slideToggle("slow");
    $(this).toggleClass("closeQ"); return false;
});
    });



    $(document).ready(function(){
$(".btn-slide2").click(function(){
    $("#panel_login").slideToggle("slow");
    $(this).toggleClass("closeL"); return false;
});
    });

I have two sliding panels. I need ONLY ONE panel open at a time. Right now they can both open. My project link is: link text

Here is my code:

    $(document).ready(function(){
$(".btn-slide").click(function(){
    $("#panel_quote").slideToggle("slow");
    $(this).toggleClass("closeQ"); return false;
});
    });



    $(document).ready(function(){
$(".btn-slide2").click(function(){
    $("#panel_login").slideToggle("slow");
    $(this).toggleClass("closeL"); return false;
});
    });

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

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

发布评论

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

评论(1

不念旧人 2024-09-24 00:38:28

我查看了您提供的链接,但看不到按钮。

反正。您可能想要的是仅显示 "#panel_quote""#panel_login"。在这种情况下,我建议在其中一个按钮上使用 hide() onload ,然后在一个按钮中像这样切换两个按钮:

$(".btn-slide").click(function(){
    $("#panel_login").slideToggle("slow");
    $("#panel_quote").slideToggle("slow");
});

或者如果您确实想使用这两个按钮,只需将另一个切换添加到每个按钮即可处理程序。同样,您可以使用 hide() onload。由于用户关闭了 javascript,因此采用这种方式比提供初始 css 值来隐藏面板更安全。

I looked at the link you provided but I couldn't see the buttons.

Anyway. What you probably want is to show only either "#panel_quote" or "#panel_login". In that case I would recommend using hide() onload on one of them and then in one button toggle both like this:

$(".btn-slide").click(function(){
    $("#panel_login").slideToggle("slow");
    $("#panel_quote").slideToggle("slow");
});

Or if you really want to use both buttons, just add the other toggle to each button handler. And again, you can use the hide() onload. It is safer to proceed this way rather than giving initial css values to hide the panel because of users with javascript turned off.

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