📌  相关文章
📜  使用 javaScript 从选择元素中获取值或文本 - 任何代码示例

📅  最后修改于: 2022-03-11 14:58:50.626000             🧑  作者: Mango

代码示例1

Running this code:

var e = document.getElementById("ddlViewBy");
var strUser = e.value;
Would make strUser be 2. If what you actually want is test2, then do this:

var e = document.getElementById("ddlViewBy");
var strUser = e.options[e.selectedIndex].text;