Marvzz
Marvzz

Reputation: 1555

Get the value of select jquery

<select id="my-select">
<option value="1">This is one</option>
<option value="2" selected>This is two</option>
...
</select>

Is there a way to get the text value of the selected option?

$('#my-select').val();

gives me 2, i want to get This is Two instead.

How?

Upvotes: 3

Views: 2815

Answers (1)

rahul
rahul

Reputation: 187030

What you want is

  1. Get the selector for finding the selected option in the select box
  2. Use .text() on the selector.

    $('#my-select option:selected').text();
    

See a working demo

Upvotes: 10

Related Questions