0

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

1 Answers1

1
$('#list').change(function() {
  var value = $("#list option:selected").text();
alert(value);
});

http://jsfiddle.net/8Y9WT/

erimerturk
  • 4,230
  • 25
  • 25