0

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.

Trevor Reid
  • 3,310
  • 4
  • 27
  • 46
Onyx
  • 5,186
  • 8
  • 39
  • 86
  • Pretty sure you just asked this same question a bit ago - if the linked canonicals aren't sufficient, please edit a [MCVE] into the question so that the problem can be reproduced, so as to make the question answerable – CertainPerformance Apr 14 '19 at 23:56
  • [You just asked this question.](https://stackoverflow.com/q/55680851/10221765) – Jack Bashford Apr 14 '19 at 23:59

0 Answers0