Reputation:
I have this;
<select id='list'>
<option value='1'>First</option>
<option value='2'>Second </option>
<option value='3'>Third </option>
</select>
i want to specifically get the option selected and put it an a variable, then alert what's in the variable.
I tried
var value = $("#list option:selected").text();
alert(value);
but its not working :(
Ps: i need the selected value in a variable.
Thanks
Upvotes: 0
Views: 124
Reputation: 4288
$('#list').change(function() {
var value = $("#list option:selected").text();
alert(value);
});
Upvotes: 1