Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
//Have to create a closure and redefine "i" inside so that the console won't throw undefined error
(function(){
var index = i;
var elem = document.getElementsByClassName('cat');
elem[index].addEventListener("click",function(){
array[index].count = array[index].count + 1;
var total= array[index].count;
var numb = document.getElementsByTagName("p")[index];
numb.innerHTML = total;
},false);
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.