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


当前回答

以下内容对我有用:

$.trim($('#dropdownId option:selected').html())

其他回答

以下内容对我有用:

$.trim($('#dropdownId option:selected').html())

这对我来说很有用:

$("#city :selected").text();

我正在使用jQuery 1.10.2

这对我有用

$("#dropdownid").change(function() {
    alert($(this).find("option:selected").text());
});

如果元素是动态创建的

$(document).on("change", "#dropdownid", function() {
    alert($(this).find("option:selected").text());
});

这对我有用:

$('#yourdropdownid').find('option:selected').text();

jQuery版本:1.9.1

如果要将结果作为列表,请使用:

x=[];
$("#list_id").children(':selected').each(function(){x.push($(this).text());})