+ 1

Bugs

im srry its a messy code, anyways the probalem is that my text when u click the wrong button doesnt work. also why for my last question it doesnt display block like the others https://code.sololearn.com/WfzACEC8T03y/?ref=app

20th Aug 2022, 1:35 AM
Your Mom
Your Mom - avatar
7 Answers
+ 2
Yes, it's again an html problem: you replaced the div elements with button elements as I suggested but actually you replaced only the opening tag (with a <button>), leaving the closing tag as a </div>, so now the html code is completely messy; replace the closing div tags with closing button tags. Moreover don't forget to close the div opened in line 54 (you should hav two closing div in lines 58 and 59, one for the div opened in line 53 and one for the div in line 54); with those fixes the code should work.
20th Aug 2022, 4:56 AM
Fabio Caputi
+ 2
Fabio Caputi in my js code. i set it to where whenver u click the right answer the other answers going back to my doors for the first question i want it so when you click the right door the other 2 become disabled = true; this is not working though. i fixed some typos (not sure if there is more) but is there something else im missing there? only my first question with the disable is working. the other 2 questions dont work
20th Aug 2022, 3:47 AM
Your Mom
Your Mom - avatar
+ 1
Describe in detail what you want your program to do. When each button is clicked what should happen?
20th Aug 2022, 3:29 AM
Chris Coder
Chris Coder - avatar
+ 1
Actually this is not a javascript problem; the issue here is related to a couple of errors in the html code: the div in line 54 (with id=thirdQ) is not closed; you should close it after line 57 so add a "</div>" (infact the closing tag of line 58 should be referred to the div with id=q3 opened in line 53). Similarly you missed to close other two divs at line 65 (the one with id=wrong2) and at line 67 (with id=wrong3). Add the closing tags (</div>) for all the three divs that I mentioned and the javascript code will work fine. Those kind of trivial problems happen when you write messy code without correct indentetion; you really should get used to coding ALWAYS with the correct indentation: with correctly indented code you would almost certainly have avoided forgetting those closing tags. Apart from that, good job. Bye, and happy (clean) coding. P.S. there is also a typo in CSS code in line 104 but this is not so important.
20th Aug 2022, 3:36 AM
Fabio Caputi
+ 1
This is also an html issue rather than a javascript issue. The disable function for the first question works because the html elements you used are actually buttons; if you applied the disabled attribute (disabled=true) to a button element it gets disabled, meaning that it no longer reacts to click events; for the following questions instead you used div elements for the answers; the div elements cannot be "disabled" to click events in the same way as buttons; the esiest fix would be to change your div elements for the answer to questions 2 and 3 in button elements in the html code (just for consistency to what you did for the first question). If you want to leave that elements as divs, another possible solution is to use the css attribute "pointer-events"; in css file you can use it as following to disable all events (like clicking, hovering, etc.) div{ pointer-events: none; } Of course, in your case you need to use it in javascript so for example in your bluf() function you should wirte the code as following: pink = document.getElementById("pink").style.pointerEvents = "none"; red = document.getElementById("red").style.pointerEvents = "none"; green = document.getElementById("green").style.pointerEvents = "none"; in order to disable the events on the pink, red and green div; then when you need to reactivate click event you will write: pink = document.getElementById("pink").style.pointerEvents = "click"; Personally I would go for the first solution (just change the div elements in button elements in your html code so you don't need to touch your javascript). Bye.
20th Aug 2022, 4:37 AM
Fabio Caputi
+ 1
uhhh Fabio Caputi k so i just saved it and not my displays arent working for skme reason, could that also be something from my html also?
20th Aug 2022, 4:38 AM
Your Mom
Your Mom - avatar
0
oh, okay so. for the first question i want whenever u press the third door it beings u to the next question. the other 2 answer will say smth like “you failed” thats my problem
20th Aug 2022, 3:30 AM
Your Mom
Your Mom - avatar