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>Click "Alert" to alert the outer HTML of the h1 element.</p> <button onclick="myFunction()">Alert</button> <script> function myFunction() { let html = document.getElementsByTagName("h1")[0].outerHTML; alert(html); } </script> </body> </html>