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
Post a Comment