[Solved] How do i get just 1 element JS [closed]


You need to verify that x is not undefined in case none of the elements have the class your looking for

var x = document.getElementsByClassName("check")[0]
if (x) {
  var y = window.getComputedStyle(x).display
  alert(y)
} else {
  alert('not found')
}

solved How do i get just 1 element JS [closed]