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> <p>How to assign an "onclick" event to a p element:</p> <p id="demo" onclick="myFunction()">Click me.</p> <script> function myFunction() { document.getElementById("demo").innerHTML = "YOU CLICKED ME!"; } </script> </body> </html>