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> <ul id="myList"> <li>Coffee</li> <li>Tea</li> </ul> <p>Click "Alert" to alert the outer HTML content of the ul element.</p> <button onclick="myFunction()">Alert</button> <script> function myFunction() { let html = document.getElementById("myList").outerHTML; alert(html); } </script> </body> </html>