0
我有一個看起來像這樣的選擇元素:訪問自定義選擇屬性值
var select = <select class="form-control" id="state-dropdown" selected="Illinois"></select>
我需要能夠訪問「選擇」的價值,但我不知道如何做到這一點。我試過select.selected,選擇[選擇],選擇:選擇
我有一個看起來像這樣的選擇元素:訪問自定義選擇屬性值
var select = <select class="form-control" id="state-dropdown" selected="Illinois"></select>
我需要能夠訪問「選擇」的價值,但我不知道如何做到這一點。我試過select.selected,選擇[選擇],選擇:選擇
可以使用element.attributes元素上訪問任何屬性[attribute_key]
https://developer.mozilla.org/en-US/docs/Web/API/Element/attributes
就是這樣!謝謝 – Linx
[獲取選定值的可能的複製在下拉列表中使用JavaScript?](http://stackoverflow.com/questions/1085801/get-selected-value-in-dropdown-list-using-javascript) –