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 Anchor Object</h1> <h2>Create an a Element</h2> <button onclick="myFunction()">Try it</button> <p>Click "Try it" to create an a element.</p> <script> function myFunction() { const x = document.createElement("A"); const t = document.createTextNode("Tutorials"); x.setAttribute("href", "https://www.w3schools.com"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>