Run ❯
Get your
own
website
Result Size:
625 x 565
×
Change Orientation
Save Code
Change Theme, Dark/Light
Go to Spaces
<!DOCTYPE html> <html> <body> <h1>HTML DOM Events</h1> <h2>The onclick Event</h2> <h3 id="demo" onclick="myFunction()">Click this text to change the color.</h3> <script> function myFunction() { document.getElementById("demo").style.color = "red"; } </script> </body> </html>