jQuery to retrieve and set selected option value of html select element

前端 未结 9 1379
醉梦人生
醉梦人生 2020-11-28 21:15

I am attempting to retrieve and set the selected value of a select element (drop down list) with jQuery.

for retrievel i have tried $(\"#myId\").find(\':select

9条回答
  •  臣服心动
    2020-11-28 21:57

    $( "#myId option:selected" ).text(); will give you the text that you selected in the drop down element. either way you can change it to .val(); to get the value of it . check the below coding

    
    

提交回复
热议问题