jquery version of array.contains

jQuery.inArray returns the first index that matches the item you searched for or -1 if it is not found:

if($.inArray(valueToMatch, theArray) > -1) alert("it's in there");

You shouldn’t need an array.remove. Use splice:

theArray.splice(startRemovingAtThisIndex, numberOfItemsToRemove);

Or, you can perform a “remove” using the jQuery.grep util:

var valueToRemove="someval";
theArray = $.grep(theArray, function(val) { return val != valueToRemove; });

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)