Can jQuery test an array for the presence of an object (either as part of the core functionality or via an avaible plugin)?
Also, I'm looking for something like array.remove
, which would remove a given object from an array. Can jQuery handle this for me?
Best Solution
jQuery.inArray returns the first index that matches the item you searched for or -1 if it is not found:
You shouldn't need an array.remove. Use splice:
Or, you can perform a "remove" using the jQuery.grep util: