Hi I'm trying to get a variable to increment by one when I click on any one of my divs.
this code works for if I click on the page or window in general:
var click = 0;
window.onclick = function () {
click++;
console.log(click);
}
but it has to only work for when I click on one of the 36 buttons inside a container.
I tried replacing "window" with my function that is connected to my div "buttons" but that didn't work.
an example of what I'm trying to do is:
var click = 0;
myFunction.onclick = function () {
click++;
console.log(click);
}
Here is my function:
var imgArray = [], [];
function onClickCard(image)
{
image.src=imgArray[parseInt(image.name.substring(0, 1)) - 1] [parseInt(image.name.substring(1, 2)) - 1];
}