You can use .indexOf () , you do not need jQuery.
If you are going to repeat this check several times you can do a function for this.
I suggest storing these numbers in arrays:
var numerosA = [1,3,5,6,7,9,10];
var numerosB = [2,4,8,11,12,17];
and then check the new number with these:
numerosA.indexOf(1) != -1 // true
numerosA.indexOf(2) != -1 // false
numerosB.indexOf(1) != -1 // false
numerosB.indexOf(2) != -1 // true
The .indexOf () gives the position of that number inside of the array. If the number does not exist in the array it will give -1
.
You can also use a ternary for this. In this case you could do:
var resultado = numerosA.indexOf(seuNumero) != -1 ? 'Sim' : 'Não';
Example applied to a function , in this example giving a third answer for erroneous cases:
var numerosA = [1, 3, 5, 6, 7, 9, 10];
var numerosB = [2, 4, 8, 11, 12, 17];
function verificar(nr) {
if (numerosA.indexOf(nr) != -1) return 'Sim!';
else if (numerosB.indexOf(nr) != -1) return 'Não!';
return 'Não existe em nenhuma...';
}
alert(verificar(1)); // Sim!
alert(verificar(2)); // Não!
alert(verificar(500)); // Não existe em nenhuma...