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


当前回答

只需尝试以下代码。

var text= $('#yourslectbox').find(":selected").text();

它返回所选选项的文本。

其他回答

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

用于获取所选值

$('#dropDownId').val();

要获取所选项目文本,请使用此行:

$("#dropDownId option:selected").text();
$("#yourdropdownid option:selected").text();

以下内容对我有用:

$.trim($('#dropdownId option:selected').html())
$("#dropdown").find(":selected").text();


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

$(“#下拉选项:selected”).text();

$("#dropdown").children(":selected").text();