Hello there. I have a while loop that adds an onclick event listener for multiple images.
I know what the prob is. The while loop increments the variable a by 1, which in turn edits the onclick attribute for the HTML tag.
Is there any way around this?
Below is the code:
function nanoboxInit () {
imgTags = document.getElementsByTagName("img");
while (a < imgTags.length) {
if (imgTags[a].className == "nanobox-img") {
imgTags[a].onclick = function () { nanoboxOpen(this); }
}
a++;
}
fatTony(0);
}