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


当前回答

$("option:selected", $("#TipoRecorde")).text()

其他回答

这里张贴的答案,例如,

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

对我来说没用,但这样做了:

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

它可能是jQuery的旧版本。

var e = document.getElementById("dropDownId");
var div = e.options[e.selectedIndex].text;

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

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

对于正在使用SharePoint列表且不想使用长时间生成的id的用户,这将起作用:

var e = $('select[title="IntenalFieldName"] option:selected').text();