简体   繁体   中英

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

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.

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.

Example for hide div :

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

Example for show div :

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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