Loading...

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

Temperature: 0 °C

Mark ChangMark Chang
author_tools

如題,透過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  #option  
https://innstory.com/story-javascript如何通過其_ID_設置選擇元素的選定選項-3144
javascript

Prev
 使用PHP資料量太大遇到Allowed_memory_size_of_134217728_bytes_exhausted_問題

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

About the Author

Mark Chang

離不開電腦的宅男

Visitor message

Leave some footprints to prove that you visited me

Recommended reading

Author's other related stories

PHP如何移除 x-powered-by 資訊

PHP如何移除 x-powe...

xpoweredby 主動披露使用程式版本訊息,增加資安風險。 可透過以下方式隱藏 xpowered...

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

使用PHP取得指定月份最後一...

使用PHP要如何抓某個月份的最後一天 例如抓本月份的話可以使用下列範例: date(&#;Ymt&#...

php檢查陣列中大於0的值

php檢查陣列中大於0的值

假設有一個陣列$a $a = array(,,,,,,); 取得大於的數值有幾個 $tempa = ...

Please select an option

error

Hi, thank you for your participation, but you cannot vote repeatedly~

Join innstory now and start recording your story.

"Innstory" is a place to store stories. We are committed to becoming a warm platform. Deepening the bonds between people is our direction.
We are convinced that the blockchain between people is not just a cold calculation. Join us now.

Wrong format