How to get <select> options either (value or text) using jQuery
- by Muhammad Sajid
Hello,
i have a code for
<select id='list'>
<option value='1'>Option A</option>
<option value='2'>Option B</option>
<option value='3'>Option C</option>
</select>
and i want that how ever i select any option, it will show in an alert message.
i have try
<script type='text/javascript'>
//var value = $("#list option[value=2]").text();
//var value = $("#list option:selected").text();
//var value = $('#list').val();
var value = $(this).val();
alert(value);
</script>
but fail.