Is there a SelectedIndex for an HTML5 DataList?

后端 未结 5 1738
情深已故
情深已故 2021-02-20 03:21

You can pick the current option of any select element:

mySelect.options[mySelect.selectedIndex]

Can I do the same wit

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-20 04:12

    Judging by specs, datalist object doesn't have selectedIndex property. But you can find it's default option, which have selected. Or compare input's value to each option value and manually find the index.

提交回复
热议问题