+ 2

Javascript

context: I am doing something like an OS in HTML with css and javascript. inside the code I have a js dictionary with the code of each "app" and when you press the button of one of the javascript apps it makes a "document.getElementById ('div'). innerHTML + = (app data)" but when opening any app and write something in a textArea or input and then open another "app" what was written in the textarea is deleted (see the code: example) also all addEventListener are removed. the question is is there another way to do the same as an innerHTML but with something similar to createTextNode (see code "createTextNode(sololearn)") https://code.sololearn.com/W5hhdnevnteh/?ref=app https://code.sololearn.com/Ws7y8HJBFApg/?ref=app

30th Nov 2021, 11:21 PM
JoseD
JoseD - avatar
5 Answers
+ 4
Html <button id="btn" onclick="addTextArea()">Click</button> <div id="demo"></div> JS let div = document.getElementById("demo"); let c=0; addTextArea = () => { let ta = document.createElement("textarea"); ta.style.color = "red"; ta.innerText = "TextArea No:" + ++c; div.appendChild(ta); } // I hope this link helps you https://code.sololearn.com/Ws0AB6J49sXO
1st Dec 2021, 12:28 AM
SoloProg
SoloProg - avatar
+ 2
Simon Sauter Yes, it's just to do something similar, just the visual part and it works https://code.sololearn.com/WDGQqJ83817M/?ref=app
30th Nov 2021, 11:51 PM
JoseD
JoseD - avatar
1st Dec 2021, 12:02 AM
JoseD
JoseD - avatar
0
Are you sure you understand what an OS is?
30th Nov 2021, 11:46 PM
Simon Sauter
Simon Sauter - avatar
30th Nov 2021, 11:57 PM
SoloProg
SoloProg - avatar