How to get the value of option select box in jQuery if I have the code like this,
I have tested your code and its works ok for me make sure about id #media does repeat from other control. Because its config and get value from last find html control
try this,
jQuery(document).ready(function() {
jQuery('#media').change(function(e) {
var id = $(this,':selected').val();
alert(id);
});
});
use this code:
$('#media').change(function(){
alert($('#media :selected').val());// or $('#media').val();
});
$("#id option:selected").val();
Here id
is the id of a select box. I'm sure it will work 100%.
If you want selected text use this one:
$("#id option:selected").text();
$('#media').change(function(){
alert($(this).val());
});
this should work the way you want it should.
make sure you use latest jquery because its working fine
http://jsfiddle.net/Hayhv/
check it give value of option