Why doesn’t my code work | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 2

Why doesn’t my code work

https://code.sololearn.com/W1bs3sJGx67s/?ref=app I have a document.getElementById but it won’t show please help

15th Jan 2019, 9:59 PM
Trevor
Trevor - avatar
2 ответов
+ 2
use "window.alert" or "console.log" instead of "document.write" and also replace line 16 ( in js code ) by that: document.getElementById("FA2").style.display = "block"; check this for more about diff between display and visibility https://stackoverflow.com/questions/3475119/css-properties-display-vs-visibility
16th Jan 2019, 12:06 AM
MO ELomari
MO ELomari - avatar
0
So you have an understanding why its not working as intended is because you are using document.write() in the hit() function. document.write() clears all HTML from the document. This is why your call to display the FA2 isn't working, because the div has been cleared from the document. https://www.w3schools.com/jsref/met_doc_write.asp
17th Jan 2019, 1:32 AM
Jay
Jay - avatar