Reputation: 173
:selected doesn't seem to work in IE7.
var selected_value0 = $("#select").find(':selected').attr('value');
Here's an example: http://jsfiddle.net/clare73/8TLqs/
Upvotes: 0
Views: 950
Reputation: 79830
Your options list doesn't have a value attribute.. and I assume that you are trying to get the text of the options, not value. If so use .text()
like below,
var selected_value0 = $("#select").find(':selected').text();
DEMO: http://jsfiddle.net/8TLqs/1/
Incase if you are trying to get the value of the selected option, then you can simply use .val()
like below,
var selected_value0 = $("#select").val()
For which HTML should be,
<select id="select">
<option value="1" selected="selected">choice 1</option>
<option value="1">choice 2</ option>
</select>
DEMO: http://jsfiddle.net/8TLqs/6/
Upvotes: 0
Reputation: 207901
Don't use .attr('value')
, instead use .val()
var selected_value0 = $("#select").find(':selected').val();
Upvotes: 1