jQuery隐藏所有打开的div并切换 [英] jquery hide all open divs and toggle

查看:114
本文介绍了jQuery隐藏所有打开的div并切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个链接,根据他们单击哪个链接,我想关闭所有其他链接并仅显示该链接的信息.

I have 2 links and depending on which one they click on want to close all others and show only the information for that link.

示例:

<div class="shipping-container">
    <a href="#" class="ups">Show UPS info</a>
    <a href="#" class="fedex">Show Fedex info</a>
    <div class="ups info" style="display:none">the info for ups</div>
    <div class="fedex info" style="display:none">the info for fedex</div>
</div>

关于如何使用Jquery切换按钮的任何想法,可单击其中一个链接并隐藏所有其他链接(如果打开的话).我只想一次显示一种运输方式的信息.另外,如果可能的话,我希望用户单击showall,并显示所有这些选项.预先感谢....

Any ideas how I can do this with Jquery toggle for clicking one of the links and hide all others if there open. I only want to show info for one shipping method at a time. Also I would like an option for the user to click showall and all of them are displayed, if possible. Thanks in advance....

推荐答案

$(".shipping-container a").click(function() {
    $("div.info").hide();
    $("div." + this.className).show();
});

您可以在这里尝试.

这篇关于jQuery隐藏所有打开的div并切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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