Last active
September 22, 2017 11:12
-
-
Save komagata/94533293aa037d205b081e03529d4a86 to your computer and use it in GitHub Desktop.
jQueryを使わず、動的にイベントリスナを追加する。
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
let elements = document.getElementsByTagName("div"); | |
Array.from(elements, (element) => { | |
if (element.classList.contains(".foo")) { | |
element.addEventListener("click", () => { | |
console.log("FOO!"); | |
}) | |
} | |
}); |
でも、これもYouのやつもやめた方がいいと思います(小声
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
なんか同僚に聞いたら、イベントのバブルアップを使って
みたいなことすればできるんじゃねって言われた。