How to change the value of a select menu onchange

I thought this was going to be a simple problem but it stumped me. Basically what I want to do is alert the id value of the option that is currently being displayed from a select menu. So if I select English, I want “en” to be alerted and if I select Spanish I want “es” alerted. So far with what I have, only “es” gets alerted regardless of which option I select. I guess it is because, the first child of the select menu is automatically chosen according to the code. So how do I make this work the way I want?
I also tried

$(“option”).change(function(){
alert($(this).attr(“id”));
});

but it didn’t work

[php]

Spanish English

[/php]

Try this

alert($(this).val());

@ M@tt, thanks. That worked.

Sponsor our Newsletter | Privacy Policy | Terms of Service