How to get the value of option select box in jQuery if I have the code like this,
I did so,
<select id='coprede' name='cop_rede'>
<option value='1'>Cop Rio de Janeiro</option>
<option value='2'>Cop Nordeste</option>
<option value='3'>Cop Vitoria</option>
<option value='4'>Cluster Norte</option>
<option value='5'>Cluster Centro Oeste</option>
</select>
within the script:
$(function(){
$('#coprede').change(function(){
alert($('#coprede :selected').val());
});
});
Use class instead of id like this..
<select class='media' name='media'>
<option value='1'>media1</option>
<option value='2'>media2</option>
<option value='3'>media3</option>
</select>
$(document).ready(function(){
$(".media").live("change",function(){
var id = $(this).val();
var dataString = 'id='+ id;
alert(id); return false;
});
});