Home > Web Front-end > JS Tutorial > jQuery determines whether the array contains the specified element_jquery

jQuery determines whether the array contains the specified element_jquery

WBOY
Release: 2016-05-16 16:10:20
Original
1980 people have browsed it

To determine whether an array contains an element, in principle, it is to traverse the entire array and then determine whether it is equal,

Copy code The code is as follows:

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

If not included in the array, return -1;

The above is the entire content of this article, friends in need can refer to it

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template