資料載入中

胡言亂語

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取得指定月份最後一天的日期 

發表留言

作者簡介

離不開電腦的宅男


推薦閱讀

作者其他相關類別故事

如何將mysql table auto_increment重設

如何將mysql table…

Mark Chang 7 年又 358 天 2.7K

資料表裡的資料加加減減,一不小心突然驚覺當初的欄位長度設定的不夠⊙⊙ 當然,你可以選擇再把欄位長度...

Android 禁止螢幕旋轉

Android 禁止螢幕旋轉

Mark Chang 7 年又 293 天 2.7K

首先找到AndroidManifest.xml檔案 位置在app/manifests/路徑底下 ...

php在windows系統下無法使用mb_send_mail寄信

php在windows系統下…

Mark Chang 6 年又 106 天 2.4K

首先,mbsendmail是php所提供可用來發送編碼的郵件。 一般來說會導致無法發送郵件大部分原因...