I am a little new to jQuery but I was wondering if there was a way to add multiple values to this:
if ($(this).find(":selected").attr('value') == "196")
Instead of having just "196" can I have an array of possible values?
I am a little new to jQuery but I was wondering if there was a way to add multiple values to this:
if ($(this).find(":selected").attr('value') == "196")
Instead of having just "196" can I have an array of possible values?
You want to find out if the value of the selected input is one of several possibilities, correct? You can create an array of possibilities and use indexOf
to see if your value matches any of them.
var selectedValue = $(this).find(':selected').attr('value'),
possibilities = [196, 666, 907];
selectedValue = +selectedValue; // coerce the value to a number
if(possibilities.indexOf(selectedValue) !== -1) {
// Your selected value matches one of the possibilities
} else {
// Your selected value does not match any of the possiblities
}