html - Javascript: Toggle visibilty of a div -


I am trying to make a div visible / invisible using javascript. I have a function that should change the visibility to 'None', if it appears in the div and the 'view' if the div is none though it does not seem to work, please help is the code.

  & lt; Script & gt; Function toggleTools () {var element = document.getElementById ('divTools'); If (element.style.visibility == 'visible') {element.style.visibility = 'hidden'; } And {element.style.visibility = 'visible'; }} & lt; / Script & gt;    

I tried your code and worked for it please find the code below Set the visibility for the element otherwise it is not working in the beginning.

  & lt; Script & gt; Function toggleTools () {var element = document.getElementById ('divTools'); If (element.style.visibility == 'visible') {element.style.visibility = 'hidden'; } And {element.style.visibility = 'visible'; }} & lt; / Script & gt; & Lt; Div id = "divTools" style = "visibility: visible" & gt; & Lt; P & gt; Some text & lt; / P & gt; & Lt; / Div & gt; & Lt; Input type = "button" onclick = "toggleTools ()" value = "click" />    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -