运行 ❯
获取您的
自己
网站
×
更改方向
保存代码
更改主题,暗色/亮色
前往 Spaces
<!DOCTYPE html> <html> <body> Select your favorite fruit: <select> <option id="myOption" value="apple">Apple</option> <option value="orange">Orange</option> </select> <p>Click the button to change the value of the apple option.</p> <button type="button" onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { document.getElementById("myOption").value = "newValue"; document.getElementById("demo").innerHTML = "The value of the value attribute of the 'apple' option has been changed from 'apple' to 'newValue'."; } </script> </body> </html>