The page works fine, but the slider doesn't slide to the next image. JSFiddle makes it work out fine and the images slide, yet on localhost or any live website it fails.
<script>
var slides = document.querySelectorAll('#slides.klant');
var currentSlide = 0;
var slideInterval = setInterval(nextSlide,2000);
function nextSlide(){
slides[currentSlide].className = 'klant';
currentSlide = (currentSlide+1)%slides.length;
slides[currentSlide].className = 'klant showing';
}
</script>
<title>Untitled Document</title>
</head>
<body>
<div id="ads">
<ul id="slides">
<li class="klant showing"><img src="img/first.jpg"></li>
<li class="klant"><img src="img/second.jpg"></li>
<li class="klant"><img src="img/third.jpg"></li>
<li class="klant"><img src="img/fourth.jpg"></li>
<li class="klant"><img src="img/fifth.jpg"></li>
</ul>
</div>
I get an error "Uncaught TypeError: Cannot set property 'className' of undefined" on the slides[currentSlide].className = 'klant'; part of the function but can't figure out what's going wrong.
headis executed beforebodyexists.<script>aslast-childof<body>(Just before closing body tag(</body>))