[ACCEPTED]-How to get text of a selected option from the select element?-jquery

Accepted answer
Score: 14

This works:

<select name="foo" id="foo">
<option value="1">a</option>
<option value="2">b</option>
<option value="3">c</option>
<input type="button" id="button" value="Button" />

$('#button').click(function() {
    alert($('#foo option:selected').text());

Try it yourself: http://jsfiddle.net/Nyenh/

Even simpler:

    var selected = $(this).find('option:selected');
    alert(selected.val() + ' ' + selected.text());



Score: 1

This will show all positions in your "dropdownlist". To 2 get only selected item use:


Or try like


instead 1 of

$("#foo option:selected").text()

More Related questions