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


当前回答

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

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

其他回答

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

Use:

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

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

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

如果您使用asp.net并编写

<Asp:dropdownlist id="ddl" runat="Server" />

那么你应该使用

$('#<%=ddl.Clientid%> option:selected').text();

$(“#DropDownID”).val()将给出选定的索引值。