css jquery隐藏一个div,显示另一个 [英] css jquery hide one div, show another
本文介绍了css jquery隐藏一个div,显示另一个的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个挑战。
在页面加载$时,我有2 divs
,一个设置为 display:none;
b $ b我有两个相应的链接。当用户点击 link1
时,我想显示 div1
并隐藏 div2
。当用户点击 link2
我想显示 div2
并隐藏 div1
。
I am having a challenge.
I have 2 divs
, one set to display:none;
in the css when the page loads
I have two corresponding links. When the user clicks on link1
I would like to show div1
and hide div2
. And when the user clicks on link2
I would like to show div2
and hide div1
.
我无法使这个工作!任何帮助非常感激。
S
I have not been able to get this to work! Any help much appreciated. S
推荐答案
这里有一个例子:
$(function () {
$(".div1, .div2").hide();
$(".link1, .link2").bind("click", function () {
$(".div1, .div2").hide();
if ($(this).attr("class") == "link1")
{
$(".div1").show();
}
else
{
$(".div2").show();
}
});
});
这里是 演示
这篇关于css jquery隐藏一个div,显示另一个的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文