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

前端 未结 30 2360
南方客
南方客 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:24

    The answers posted here, for example,

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

    didn't work for me, but this did:

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

    It is possibly an older version of jQuery.

提交回复
热议问题