var arr = [ "One", "Two", "Three" ];
$('select[name="class"]').change(function() {
if (jQuery.inArray("blah blah", arr)) {
alert("OK");
}
});
this is alerting "OK", yet "blah blah" isn't in the array... what am I doing wrong?
The jQuery.inArray function always returns a value:
Description: Search for a specified value within an array and return its index (or -1 if not found).
Docs: http://api.jquery.com/jQuery.inArray/
Change your code to:
if (jQuery.inArray('blah blah', arr)) >= 0) {
alert('Ok');
}