What Javascript code can I use to write to the HTML DOM? I want to create a button which each time I click it, it writes different text to a document element? Example;
first click:
document.getElementById("paragraph").innerHTML= "This is is the initial text."
second click:
document.getElementById("paragraph").innerHTML= "This text replaces the initial text"
third click:
document.getElementById("paragraph").innerHTML= "This text replaces the text from the second click"
and so forth and so forth…
All without
Thanks in advance.
Add all the text options into an array.
Set up a variable that counts up with each click.
Call the text from the array using the number of the counter.
Some code: