執行 ❯
建立您
自己的
網站
×
更改方向
儲存程式碼
更改主題,深色/淺色
轉到 Spaces
<!DOCTYPE html> <html> <body> <p>Click the button to create a SELECT and an OPTION element.</p> <button onclick="myFunction()">Try it</button> <script> function myFunction() { var x = document.createElement("SELECT"); x.setAttribute("id", "mySelect"); document.body.appendChild(x); var z = document.createElement("option"); z.setAttribute("value", "volvocar"); var t = document.createTextNode("Volvo"); z.appendChild(t); document.getElementById("mySelect").appendChild(z); } </script> </body> </html>