javascript - jQuery: how to check if a specific element is already in an array -


this question has answer here:

how can check if var element exists or not in array sites?

var sites = array['test','about','try']; var element = 'other'; 

you can use indexof() method following.

if(sites.indexof(element) > -1) {     //exist } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -