<!DOCTYPE html> <html> <body> <h2>What Can JavaScript Do?</h2> <p id="demo">JavaScript can change HTML content.</p> <button type="button" onclick='document.getElementById("demo").innerHTML = "Hello JavaScript!"'>Click Me!</button> </body> </html>
Code Description: JavaScript Can Change HTML Content One of many JavaScript HTML methods is getElementById(). The example above "finds" an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript":
One of many JavaScript HTML methods is getElementById().
getElementById()
The example above "finds" an HTML element (with id="demo"), and changes the element content (innerHTML) to "Hello JavaScript":
JavaScript can change HTML content.