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


当前回答

这段代码对我有用。

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

其他回答

这段代码对我有用。

$("#yourdropdownid").children("option").filter(":selected").text();
$("#dropdown").find(":selected").text();


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

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

$("#dropdown").children(":selected").text();
$("select[id=yourDropdownid] option:selected").text()

这很好

只需尝试以下代码。

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

它返回所选选项的文本。

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