so I'm quite new to Javascript, and I'm building a web matching game, and I have a 6 X 4 grid of boxes that are clickable. I want the grapic that is situated behind the box to pop out the top when I click on it.
The HTML elements of the box graphic are stored in an array as well as the characers (enemies).
Here's my code:
for(var i = 0; i < box.length; i++)
{
box[i].style.cursor = "pointer";
box[i].addEventListener("click", clickHandlerBox, false);
function clickHandlerBox()
{
enemy[i].style.top = (enemy[i].style.top + 10) + 'px';
clickBox.play();
}
}
I know the answer is probably simple and staring me in the face, but any help would definitely be appreciated. Thanks!