執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
前往 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://w3schools.tw"); x.appendChild(t); document.body.appendChild(x); } </script> </body> </html>