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>The Element Object</h1> <h2>The outerHTML Property</h2> <p id="myP">I am a paragraph! Click "Change" to replace me with a header.</p> <button onclick="myFunction()">Change</button> <script> function myFunction() { const element = document.getElementById("myP"); element.outerHTML = "<h2>This is a h2 element.</h2>"; } </script> </body> </html>