Get selected text from a drop-down list (select bo

2018-12-31 02:32发布

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

30条回答
骚的不知所云
2楼-- · 2018-12-31 03:15

Try:

$var = jQuery("#dropdownid option:selected").val();
   alert ($var);

Or to get the text of the option, use text():

$var = jQuery("#dropdownid option:selected").text();
   alert ($var);

More Info:

查看更多
明月照影归
3楼-- · 2018-12-31 03:17

Try this:

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

For an ASP.NET dropdown you can use the following selector:

$("[id*='MyDropDownId'] :selected")
查看更多
明月照影归
4楼-- · 2018-12-31 03:18

For getting selected value use

$('#dropDownId').val();

and for getting selected item text use this line:

$("#dropDownId option:selected").text();
查看更多
忆尘夕之涩
5楼-- · 2018-12-31 03:20
$("#dropdownID").change(function(){
  alert($('option:selected', $(this)).text());
});
查看更多
孤独寂梦人
6楼-- · 2018-12-31 03:20

In sibling case

<a class="uibutton confirm addClient" href="javascript:void(0);">ADD Client</a>
<input type="text" placeholder="Enter client name" style="margin: 5px;float: right" class="clientsearch large" />
<select class="mychzn-select clientList">
  <option value="">Select Client name....</option>
  <option value="1">abc</option>
</select>


 /*jQuery*/
 $(this).siblings('select').children(':selected').text()
查看更多
长期被迫恋爱
7楼-- · 2018-12-31 03:22
$('#id').find('option:selected').text();
查看更多
登录 后发表回答