Better use this instead: https://api.jquery.com/jQuery.inArray/