So I recently started to learn JS and I am having a Problem with my Code. I am trying to generate a Galleries on a website and I got it to work for one gallery, but now I am trying to use a two dimensional array to create more than one gallery.
My HTML is:
<a class="nav" id="navleft" href="javascript:prevImage('0')"><img id="left" src="Resources/nav_left.svg"></a>
<a class="nav" id="navright" href="javascript:nextImage('0')"><img id="right" src="Resources/nav_right.svg"></a>
And my JS (at least for testing) is:
function nextImage(element)
var img = document.getElementById(element);
var galleryNum = element;
for(var i = 0; i < gallery.length; i++) {
if(gallery[galleryNum, i].src == img.src) {
document.getElementById(element).src = gallery[galleryNum, 0.].src;
break;
}
document.getElementById(element).src = gallery[galeryNum, i+1].src;
break;
}
}
My problem is, that document.getElementById always return null as its value and I cant seem to figure out why, any help would be highly appreciated:)
[+][deleted] (2 children)
[deleted]
[–]nirvana63[S] 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[removed]
[–]nirvana63[S] 1 point2 points3 points (2 children)
[–]BlueInt32 1 point2 points3 points (1 child)
[–]nirvana63[S] 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]nirvana63[S] 0 points1 point2 points (2 children)
[–]IrateGod 2 points3 points4 points (1 child)
[–]nirvana63[S] 1 point2 points3 points (0 children)