如何在 HTML 页面加载时指定某个选项应被预选?
htmlweb developmentfront end technology更新于 2025/8/16 15:08:17
使用 selected 属性指定在 HTML 页面加载时该选项应被预选。您可以尝试运行以下代码来实现 selected 属性 −
示例
<!DOCTYPE html> <html> <head> <title>HTML selected attribute</title> </head> <body> <p>Here's the list of subjects. Select any one:</p> <form> <select name = "dropdown"> <option value = "Computer Architecture" selected>Computer Architecture</option> <option value = "Java">Java</option> <option value = "Discrete Mathematics">Discrete Mathematics</option> </select> </form> </body> </html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

