+ 4

Who would help me solving this problem ? The problem is, my question and answer to disappear after the door is open,but how ?

https://code.sololearn.com/W8P4P5D95cR1/?ref=app

4th Jan 2021, 2:15 PM
Riselda Rada
Riselda Rada - avatar
5 Respostas
+ 3
You could try something like this: // <![CDATA[ function open1(){ var dor = document.getElementById("dose1"); dor.style.transform = "rotateY(85deg)"; dor.style.transition = "5s"; dor.style.marginLeft = "-40%"; // hide question and answer after 5 seconds. setTimeout(hideQuestionAnswer, 5000); } function hideQuestionAnswer(){ var questionAnswerElements = document.querySelectorAll('body > p, body > mark'); questionAnswerElements.forEach(function(e) { e.remove(); }); } // ]]> I added the CDATA comments because the < and > are invalid in HTML text nodes such as the JavaScript snippet. It'll work without the CDATA comments but it won't pass validation and the browser will start using quirks mode. You could call hideQuestionAnswer immediately if you want it removed immediately. I just wasn't sure when you wanted that to happen. It would be simpler if you wrap your question and answer elements with a single div and set a descriptive id such as "question-answer" on it. This way, the hideQuestionAnswer function's code can be as simple as: function hideQuestionAnswer(){ document.getElementById('question-answer').remove(); }
4th Jan 2021, 6:42 PM
Josh Greig
Josh Greig - avatar
+ 4
Use Css opacity..I think it may help u✌🏻
4th Jan 2021, 6:44 PM
SooraJ✌🏻😐
SooraJ✌🏻😐 - avatar
+ 3
Ok .Thank you 🙏🏻
4th Jan 2021, 8:17 PM
Riselda Rada
Riselda Rada - avatar
+ 3
Josh Greig i did it but there is no result , something is going wrong with my code , would you help me please ?
4th Jan 2021, 8:43 PM
Riselda Rada
Riselda Rada - avatar
+ 1
You have 2 open functions. Did you test with open2 instead of open1? open2 corresponds with the blue door. If you want the question and answer to close whenever either door opens, make sure this line is in both the open1 and open2 functions: setTimeout(hideQuestionAnswer, 5000);
5th Jan 2021, 12:38 AM
Josh Greig
Josh Greig - avatar