Onclick Show / Hide Multiple Divs Jquery

前端 未结 5 1231
萌比男神i
萌比男神i 2021-01-22 14:24

I need to create navigation that shows / hides multiple divs.

Here is what I need to be able to do: If a user clicks on any of the \"options

5条回答
  •  深忆病人
    2021-01-22 14:26

    EDIT: for a non JQuery solution try this:

    function showHide(element) { 
         var field = document.getElementById(element); 
         if (element) { 
              if (field.style.display == 'none') { 
                    field.style.display = 'block'; 
              } else { 
                    field.style.display = 'none'; 
              } 
         } 
    }
    

    That would be your code to show and hide in your JS

    That should get you started :-)

    Totally missed the Jquery my bad

提交回复
热议问题