How do I get the selected value from a dropdown list in case there are more than one selected item using JavaScript?
(万一使用JavaScript有多个选定项,如何从下拉列表中获得选定值?)
like this:(像这样:)
<select name"nana" id="nana">
<option value="0"</option>
<option value="1"</option>
<option selected="selected" value="2"</option>
<option value="3"</option>
<option selected="selected" value="4"</option>
</select>
I tried:
(我试过了:)
var e = document.getElementById("nana");
var strUser = e.options[e.selectedIndex].value;
document.querySelector("nana").value;
and its return only the first selected value (2), how can i get all of the selected items?
(并且它仅返回第一个选定的值(2),如何获得所有选定的项?)
ask by EladMag translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…