Javascript toggle visibility multiple divs

后端 未结 4 1758
难免孤独
难免孤独 2020-12-20 04:14

http://blog.movalog.com/a/javascript-toggle-visibility/

this is a page with some code and a script im using in my site for an image gallery, however when trying to t

4条回答
  •  伪装坚强ぢ
    2020-12-20 04:45

    You either need to cycle through a list of ids or use a class name as the argument to toggle_visibilty ---- which means you would have to edit the function. It looks like right now you are only calling toggle_visibility on one element.

    jQuery makes this kind of thing easier:

      
      //selects all elements with class="yourClassName"
      jQuery(".yourClassName").toggle();
    
      //select all divs
       jQuery("div").toogle();
    
      //select all divs inside a container with id="myId"
     jQuery("#myId > div").toggle();
     
    

提交回复
热议问题