DOM - Changing the content of the html
It is possible to change the content of an HTML page dynamically using the DOM. Take a look at the following example
<!DOCTYPE html> <html> <head> <script> /* ************************************ ReferenceDesigner.com DOM Tutorial ************************************ */ function addText() { document.getElementById("addtxt").innerHTML="New text"; } </script> </head> <body> <p>Click the button and it will add some text.</p> <button onclick="addText()">Hit me</button> <p id="addtxt">some text</p> </body> </html> |
When the button is clicked the contents of the paragraph is changed.
You may like to try this example here.