0
Can we code it without disappear the button?
2 odpowiedzi
+ 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>
+ 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.