如何从jQuery的下拉列表中获取所选文本(而不是所选值)?
当前回答
这对我有用:
$('#yourdropdownid').find('option:selected').text();
jQuery版本:1.9.1
其他回答
以下内容对我有用:
$.trim($('#dropdownId option:selected').html())
$("#dropdownID").change(function(){
alert($('option:selected', $(this)).text());
});
只需尝试以下代码。
var text= $('#yourslectbox').find(":selected").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>
Use:
('#yourdropdownid').find(':selected').text();