The code is fine, you just do not initialize it correctly.
Try it ....
$(document).ready(function() { $("select").change(function(){ alert(this.id); }); });
see the documentation here .
Your function notifies the id
of the select
element (which you in no way assigned). I assume you really wanted to get the value from the drop down list? In this case, you want:
alert($(this).val());
fearofawhackplanet
source share