This site is mobile accessible. Press the "Tap Here" button to use a larger font-size.
Smartphone icons created by Freepik - Flaticon
The HTML DOM allows JavaScript to change the content of HTML elements.
document.getElementById(id).innerHTML = new HTML
This example changes the content of a
element:<html> <body> <p id="p1">Hello World!</p> <script> document.getElementById("p1").innerHTML = "New text!"; </script> </body> </html>
<!DOCTYPE html> <html> <body> <h1 id="id01">Old Heading</h1> <script> const element = document.getElementById("id01"); element.innerHTML = "New Heading"; </script> </body> </html>
To change the value of an HTML attribute, use this syntax:
document.getElementById(id).attribute = new value
This example changes the value of the src attribute of an
element:<!DOCTYPE html> <html> <body> <img id="myImage" src="smiley.gif"> <script> document.getElementById("myImage").src = "landscape.jpg"; </script> </body> </html>
<!DOCTYPE html> <html> <body> <script> document.getElementById("demo").innerHTML = "Date : " + Date(); </script> </body> </html>
In JavaScript,
can be used to write directly to the HTML output stream:<!DOCTYPE html> <html> <body> <p>Bla bla bla</p> <script> document.write(Date()); </script> <p>Bla bla bla</p> </body> </html>
Eventually the navigation links, above, will be replaced by these (previous) and (next) buttons below.
JavaScript icons used in the buttons provided by ICONS8.COM. Smartphone icons created by Freepik - Flaticon