【JavaScript】select元素相關操作

#mySelect.options

回傳選項清單

select#mySelect
 option apple
 option banana
 option grape
console.log(mySelect.options)
//回傳所有options的集合
//型態為HTMLOptionsCollection

#mySelect.selectedIndex

回傳目前被選取到的index

select#mySelect
 option apple
 option banana
 option grape
console.log(mySelect.selectedIndex)
//0