I am trying to add a class to an element that I select like this:
const element = document.getElementsByClassName('some class names')
If I console.log
this element (console.log('element?', element
), I get a collection of HTML elements; but if I console.log
one element (console.log('element[0]?', element[0])
), it's undefined
.
Does anyone know why I can't access an element from that collection?
const legendSymbol = document.getElementsByClassName("esri-legend__layer-cell--symbols")
legendSymbol[0].classList.add('hidden')