Get selected text from a drop-down list (select box) using jQuery

前端 未结 30 1681
南方客
南方客 2020-11-21 15:58

How can I get the selected text (not the selected value) from a drop-down list in jQuery?

30条回答
  •  清酒与你
    2020-11-21 16:28

    If you already have the dropdownlist available in a variable, this is what works for me:

    $("option:selected", myVar).text()
    

    The other answers on this question helped me, but ultimately the jQuery forum thread $(this + "option:selected").attr("rel") option selected is not working in IE helped the most.

    Update: fixed the above link

提交回复
热议问题