I'm trying to change the display style property of slides[0]
to block using:
let slides = document.getElementsByClassName("mySlides");
slides[0].style.display = "block";
However, slides[0]
seems to be undefined even though console.log(slides)
returns a HTMLCollection
with 10 divs in it.
I'm not sure if this matters, but the function that uses this code exists in the mounted()
lifecycle hook of Vue.js. I executed the same code inside an HTML file where the JavaScript was in the tag and it worked fine.