Created
October 1, 2018 16:04
-
-
Save manekinekko/b8a1be9a9ba1a8411ec5b163480698b1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
const elements = document.querySelectorAll('button'); | |
const len = elements.length; // 8 par exemple | |
for(let i=0; i<len; i+=1){ | |
elements[i].addEventListener('click', function() { | |
alert(i+1) | |
}, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment