Why won’t the “div”s disappear? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why won’t the “div”s disappear?

I am new and making a project, but I have hit a roadblock. I made this demonstration to show my problem. I have already tried: -Turning the opacity to 0.0 -Adding “.style” -Moving the “div”s off of the page -Rearranging the order of the code How do I make the red rectangle disappear when it is clicked? https://code.sololearn.com/WjRXII7LxJVO/?ref=app

14th Feb 2020, 11:37 PM
Mikhail
1 Answer
+ 7
document.getElementsByTagName returns an array, so it considered ".display" as an array attribute, which is not the case. You should select only the first element, using document.getElementsByTagName[0], here is the code: https://code.sololearn.com/Wo8Oy3wcUiZF/?ref=app
14th Feb 2020, 11:40 PM
Aymane Boukrouh
Aymane Boukrouh - avatar