Show/Hide Multiple Divs Javascript

后端 未结 4 1582
别跟我提以往
别跟我提以往 2020-12-11 06:30

Looking for a good JavaScript to help me hide/show multiple divs with a button click not an a href click so I can use it in blogger. I\'ve been looking for an answer for a w

4条回答
  •  有刺的猬
    2020-12-11 07:05

    if you want to hide/show all divs simultaneously than you have to give all divs same class for ex: .toggle and than you can do this:

    function myFunction1(){
        $(".toggle").slideToggle();
    }
    

    if you want to hide/show one div at a time than you can do this with id :

    function myFunction1(){
        $("#myDIV1").slideToggle();
    }
    

    with different buttons :

    function myFunction1(id){
        $("#"+id).slideToggle();
    }
    

    pass id here :

    
    
    
    
    

提交回复
热议问题