使用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中如何指定選項在頁面載入時應預先選取?的詳細內容。更多資訊請關注PHP中文網其他相關文章!