I am following W3Schools' tutorial on creating a Slideshow in HTML/CSS/Javascript, located here. In the HTML code, I have created several elements that are within the mySlides class; however, when I call document.getElementsByClassName("mySlides") I get a null array.
Here is some of the HTML code of elements within the mySlides class:
<div class="mySlides fade">
<div id="intro">
<p>Click to Start!</p>
<button type="button" id="startButton" onclick="start()">Start!</button>
</div>
</div>
Here is the Javascript code where I call upon accessing the mySlides elements:
var slides = document.getElementsByClassName("mySlides");
console.log(slides.length); // prints "0"
console.log(slides[0]); // prints "undefined"
Any ideas on why document.getElementsByClassName("mySlides") isn't able to access the mySlides elements? Thank you for your help.