I'd go with Felix's suggestion. But just for completeness:
On browsers that have the indexOf
on arrays, you could do:
if ([105, 74].indexOf(parseInt($('#address_nations_id').val())) >= 0)
...but I wouldn't recommend it for just two values. It's less clear, unnecessarily complex, and not all browsers have it (yet). Most of those criticisms apply to using jQuery's inArray
function as well.
There's also switch
:
switch (parseInt($('#address_nations_id').val())) {
case 105:
case 74:
break;
default:
/* do your thing here *?
break;
}
...but that hardly qualifies as shorter, almost certainly wouldn't be appropriate for just two values.