简体   繁体   English

如何在 div 单击时隐藏/显示?

[英]How to hide/show on div click?

I have a div that I'm trying to show and hide on a click of another div我有一个 div,我试图通过单击另一个 div 来显示和隐藏

The code I'm using is:我正在使用的代码是:

$(document).ready(function(){
    $(".logoo").click(function(){
        $("ul.secondone").show(1000);
    });

});

How do I add the hide function as well?如何添加隐藏功能? I tried changing the .show to .hide but it didn't work.我尝试将 .show 更改为 .hide 但它没有用。

Okay sorry for asking this question in a hurry I have figured the code out.好的很抱歉匆忙问这个问题我已经弄清楚了代码。

jQuery(document).ready(function(){
    jQuery('.logoo').on('click', function(event) {        
        jQuery('ul.secondone').toggle('show');
    });
})

You can hide or show division using jQuery.您可以使用 jQuery 隐藏或显示除法。

Example for hide div :隐藏 div 示例:

$("#divId").click(function(){
  $("divToHide").hide();
});

Example for show div :显示 div 示例:

$("#divId").click(function(){
  $("divToShow").show();
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM