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


当前回答

这对我有用:

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

jQuery版本:1.9.1

其他回答

$("#dropdownid").change(function(el) {
    console.log(el.value);
});

或者你可以用这个

$("#dropdownid").change(function() {
    console.log($(this).val());
});
$("option:selected", $("#TipoRecorde")).text()
$("#dropdownID").change(function(){
  alert($('option:selected', $(this)).text());
});

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

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

这对我有用

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

如果元素是动态创建的

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