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
Post a Comment