資料載入中

胡言亂語

javascript如何通過其 ID 設置選擇元素的選定選項?

如題,透過javascript來針對某個select的option來做選定。
document.getElementById("要用來設置select的ID").selectedIndex=第幾個option;

或者
document.getElementById("要用來設置select的ID").options.namedItem("第幾個option").selected=true;

或者
document.getElementById("要用來設置select的ID").options[第幾個option].selected=true;

以上紀錄~
 

  • 透過javascript選擇select選項
  • javascript操作select選項
  • 選定特定select的option
  • 使用javascript修改select選項
  • select選項的javascript應用
https://innstory.com/story-javascript如何通過其ID設置選擇元素的選定選項?-3144

上一篇
 使用PHP資料量太大遇到Allowedmemorysizeof134217728bytesexhausted問題

下一篇
使用PHP取得指定月份最後一天的日期 

發表留言

作者簡介

離不開電腦的宅男


推薦閱讀

作者其他相關類別故事

javascript獲取當前時間

javascript獲取當前…

Mark Chang 7 年又 229 天 1.2K

以上紀錄~

Android UI設計距離課題

Android UI設計距離…

Mark Chang 7 年又 86 天 2.1K

layoutmarginTop指定該屬性所在控件距離上方的位置空間。 layoutmarginBot...

PDO PHP - PDOException - Numeric value out of range 1264 Out of range value for column user_ip at row 1

PDO PHP - PDOE…

Mark Chang 5 年又 27 天 1.5K

最近遇到一個問題,一個Mysql的錯誤訊息。 我想要紀錄一個IP資訊,我會先用以下方式擷取用戶端使用...