jquery - Alert on value change in select -


i'm trying alert user when value of select changes specific one, have multiple select in page (one each user).

here tried: http://jsfiddle.net/mefqq/

$(document).ready(function() {     $("select").change(function(){         if($(this).text() == "chef")             {                 alert();             }         }); }); 

my wish have alert when select changes value "chef".

how do this?

something perhaps: http://jsfiddle.net/mefqq/1/

you need use .val() function, not .text() function when working selects.

also need compare value attribute (1 in case) not actual text value.

the code looks this:

$(document).ready(function() {     $("select").change(function(){         if($(this).val() == "1")             {                 alert('value 1 (wich refers chef) got selected');             }         }); }); 

Comments

Popular posts from this blog

android - getbluetoothservice() called with no bluetoothmanagercallback -

sql - ASP.NET SqlDataSource, like on SelectCommand -

ios - Undefined symbols for architecture armv7: "_OBJC_CLASS_$_SSZipArchive" -