A Pen by Jeff Smykil on CodePen.
Created
August 16, 2019 19:36
-
-
Save smykes/3f74ae9bf607aada846f5241257514d9 to your computer and use it in GitHub Desktop.
VwZjaXw
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
<button id="click-1"> | |
Test | |
</button> | |
<div class="drawer hide"> | |
<button class="btn" id="red">Red</button> | |
<button class="btn" id="green">Green</button> | |
</div> |
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
document.getElementById("click-1").addEventListener("click", function() { | |
const test = document.getElementsByClassName("drawer")[0]; | |
// console.log(test.classList); | |
console.log(test.classList[1]); | |
if (test.classList[1] === "hide") { | |
test.classList.remove("hide"); | |
} else { | |
test.classList.add("hide"); | |
} | |
}); | |
const btns = document.getElementsByClassName('btn'); | |
console.log(btns.length); | |
for (let i = 0; i < btns.length; i+=1) { | |
document.getElementsByClassName('btn')[i].addEventListener('click', function() { | |
alert(); | |
}); | |
} |
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
.drawer { | |
&.hide { | |
display: none; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment