jquery - 隐藏两个 DIV 并在单击时切换第三个 DIV,然后反转

标签 jquery html hide

单击时,我的函数会隐藏前两个 DIV 并切换第三个 DIV。这是有效的。当我再次单击同一链接时,函数切换回第三个 DIV,这也有效。但是之前隐藏的两个 DIV 现在仍然隐藏,而它们应该是可见的。

<div>
    <div id="one"></div>
    <div id="two"></div>
    <div id="three"></div> -->CSS style is hidden
</div>
$(document).ready(function(){
    $("#three").hide();
    $(".show_hide").show(); --> this shows my click link

    $('.show_hide').click(function(){
        $("#three").slideToggle().load('testpage.php');
                $("#one").hide();
                $("#two").hide();
    })
});

最佳答案

改变这个...

$("#one").hide();
$("#two").hide();

对此...

$("#one").toggle();
$("#two").toggle();

或者这个...

$("#one,#two").toggle();

或者这个...

$(this).siblings().toggle();

关于jquery - 隐藏两个 DIV 并在单击时切换第三个 DIV,然后反转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8579722/

相关文章:

html - Safari 浏览器的背景色保持白色

c# - 如何隐藏devexpress XtraGrid的列

excel - application.visible=true 多个工作簿

javascript - Ajax POST 无法正常工作,PHP 对应的工作完美

javascript - 在 jquery 中找到将 css 应用于所有跨度

javascript - 为用户交互设置计时器

treeview - Doxygen:如何在 TreeView 中隐藏某些页面

javascript - 当值为空时删除数组对象

html - 边框半径在 opera browser-11.1 中不起作用

javascript - jQuery 函数的问题