jQuery determines whether the array contains the specified elements

  • 2020-05-12 02:15:16
  • OfStack

To determine whether an array contains an element, in principle, is to walk through the entire array and determine if it is equal,


var arr = [ "xml", "html", "css", "js" ];
$.inArray("js", arr);  // return 3,

If it is not in the array, -1 is returned.

The above is the entire content of this article, there is a need for the companion reference


Related articles: