如何从jQuery的下拉列表中获取所选文本(而不是所选值)?


当前回答

各种方式

1. $("#myselect option:selected").text();

2. $("#myselect :selected").text();

3. $("#myselect").children(":selected").text();

4. $("#myselect").find(":selected").text();

其他回答

$(“#DropDownID”).val()将给出选定的索引值。

以下内容对我有用:

$.trim($('#dropdownId option:selected').html())
var e = document.getElementById("dropDownId");
var div = e.options[e.selectedIndex].text;

对于多选:

$("#yourdropdownid :selected").map(function(i, v) { return $.trim($(v).text()); }

Try

dropdown.selectedOptions[0].text

函数read(){console.log(下拉列表.selectedOptions[0].text);}<select id=“下拉列表”><option value=“1”>第一个</option><option value=“2”>秒</option></选择><button onclick=“read()”>read</button>