0

Can we code it without disappear the button?

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

19th Oct 2017, 6:08 PM
Ali Murtaza
Ali Murtaza - avatar
2 Antworten
+ 2
If you want the button label to change, add an id to your button definition: <button id="update" onclick=hiThere()> Replace your document.write line with: document.getElementById("update").innerHTML="Hi there!"; You could also add do it by adding a paragraph, instead of changing the button: <p id="update"></p>
19th Oct 2017, 6:27 PM
John Wells
John Wells - avatar
+ 4
When you use document.write, you're overwriting the entire document. Try to use something like .innerHTML or innerTEXT to append your output to another element. This will prevent it from clearing everything and replacing it with whatever you put in document.write(). Hope that helps.
19th Oct 2017, 6:12 PM
AgentSmith