Created
June 20, 2019 13:50
-
-
Save renemorozowich/a35867f4159af144dc82d70d0a271c63 to your computer and use it in GitHub Desktop.
Basic JS file with a toggle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// get the button | |
var btnContent = document.getElementById("btn-content"); | |
// add a click event | |
btnContent.addEventListener("click", toggleContent); | |
// get the content | |
var content = document.getElementById("content"); | |
// hide by default | |
content.style.display = "none"; | |
// when button is clicked, show/hide | |
function toggleContent() { | |
var myContent = document.getElementById("content"); | |
if (myContent.style.display === "none") { | |
myContent.style.display = "block"; | |
} else { | |
myContent.style.display = "none"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment