Created
May 10, 2016 18:50
-
-
Save maximishchenko/6ebefced4f790423c42d84756cd5df40 to your computer and use it in GitHub Desktop.
JS Toggle Div on Button Onclick
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
<div id="target_div_id"></div> | |
<button id='button_id'>Click</button> | |
var button = document.getElementById('button_id'); | |
button.onclick = function() { | |
var div = document.getElementById('target_div_id'); | |
if (div.style.display !== 'none') { | |
div.style.display = 'none'; | |
} | |
else { | |
div.style.display = 'block'; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment