+ 1

I added an onclick event to this green box but it did not work

Onclick not working for my code https://code.sololearn.com/W6LGd6lSvZmu/?ref=app PanicS

19th Nov 2021, 7:24 PM
D Doyen
D Doyen - avatar
7 Respuestas
+ 3
write "getElementById" in camelCase
19th Nov 2021, 7:28 PM
zexu knub
zexu knub - avatar
+ 2
function mtsc() { var x = document.getElementById("bes"); x.style.display="none"; }
19th Nov 2021, 8:22 PM
JaScript
JaScript - avatar
+ 2
The result of getElementByTagName is an array so you should use a loop such as for or foreach. In your case: for(var i of d){ i.onclick = function (){ a.style.display = "block"; } }
21st Nov 2021, 2:05 PM
Jalal Matoori
Jalal Matoori - avatar
+ 1
Thanks zexu knub and JaScript it was camel case problem
19th Nov 2021, 8:24 PM
D Doyen
D Doyen - avatar
0
zexu knub it says type error undefined
19th Nov 2021, 7:32 PM
D Doyen
D Doyen - avatar
0
D Doyen use CAPS for ById
19th Nov 2021, 7:34 PM
zexu knub
zexu knub - avatar
19th Nov 2021, 7:37 PM
zexu knub
zexu knub - avatar