Jquery select change -
<select id="nazione" name="nazione"> <option prefix='+93' value='af' >afghanistan </option> <option prefix='+355' value='al' >albania </option> <option prefix='+213' value='dz' >algeria </option> <option prefix='+376' value='ad' >andorra .... etc </select>
and js
$(document).ready(function() { $('#nazione').change(function(){ alert( $(this).find("option:selected").attr('prefix') ); alert( $(this).attr('prefix') ); }); });
i have alert null... why?
your code fine. here's demo : http://jsfiddle.net/hkktc/1/
the reason you're not getting value second alert call because attribute prefix
doesn't exist select
, exists option
Comments
Post a Comment