Created
November 14, 2014 08:27
-
-
Save kulerbox/a314223113c25aa394cf 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
//create an array from classes | |
var jsClass = document.getElementsByClassName("jsClass"); | |
//loop through the length of the array | |
for (var i = 0; i < jsClass.length; i++) { | |
//assign a onclick event to each element | |
jsClass[i].onclick = function() { | |
//this will be the actual element. So you can use this.id to get the element's id | |
var thisId = this.id; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment