Created
July 2, 2018 11:00
-
-
Save SvSven/f7c887960ac1d8607aa703a621051618 to your computer and use it in GitHub Desktop.
add an eventlistener to a group of elements using querySelectorAll
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
var btns = document.querySelectorAll('.btn'); | |
for(var i = 0; i < btns.length; i++) { | |
btns[i].addEventListener('click', function() { | |
// Do stuff | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment