i am trying to add hcaptcha to my website but i am doing it in a strange way i want to get if the div with the class ‘check’ is hidden or not but i cannot do it.
here is my code
var x = document.getElementsByClassName("check")[0]
var y = window.getComputedStyle(x).display
alert(y)
it gives me the error ‘cip.html:62 Uncaught TypeError: Failed to execute ‘getComputedStyle’ on ‘Window’: parameter 1 is not of type ‘Element’.
at cip.html:62′
>Solution :
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')
}