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

使用CSS 讓ul li 橫向水平

使用CSS 讓ul li 橫...

好吧,其實這個css常在用,但我每次都沒特別紀錄,然後每次又忘記然後又要Google。 其實主要就是...

使用.htaccess關閉特定文件的緩存

使用.htaccess關閉特...

以特定檔案為例 <Files page.php> FileETag None Header unse...

Ubuntu環境下apache 目錄啟動.htaccess 功能

Ubuntu環境下apach...

.htaccess 檔案是目錄層面的設定檔,可以對目錄變更 Apache 的設定。 要使用 .hta...

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