html - Javascript: Div is opening but not collapsing back -


I have this div that I have created, I want to expand it when a link is clicked and it Click again It seems that it is expanding correctly, but it has not been eliminated. Please

  & lt; Script & gt; Function Set Display () {document.getElementById ('divCollapse'). Style.display = "none"; } Function expandselected () {if document.getElementById ('divCollapse') style.display = "none") {document.getElementById ('divCollapse'). Style.display = "block";} and if (document.getElementById) ('divCollapse') style.display = "block") {document.getElementById ('divCollapse'). style.display = "none";}} & lt; / Script & gt;    

To use == to compare you Your if / else if is the block you are currently using = which is setting a display, is not checking it.

  & lt; Script & gt; Function Set Display () {document.getElementById ('divCollapse'). Style.display = "none"; } Function expandselected () {if document.getElementById ('divCollapse') style.display == "none") {document.getElementById ('divCollapse'). Style.display = "block";} and if (document style.isplay.com ('divCollapse'). Style.display = "none";}}  element 'divCollapse'. Style .display == "block") {document.getElementById ('divCollapse').    

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 -