Home > Web Front-end > JS Tutorial > How to determine whether a jquery array contains an element

How to determine whether a jquery array contains an element

藏色散人
Release: 2022-12-30 11:13:13
Original
5642 people have browsed it

How to determine whether a jquery array contains an element: First create a front-end sample file; then define a set of array data; finally use the "$.inArray("js", arr);" method to determine whether the array contains Just include an element.

How to determine whether a jquery array contains an element

The operating environment of this article: windows7 system, jquery1.2.6, Dell G3 computer.

JQuery determines whether an element is included in the array $.inArray("js", arr);

var arr = [ "xml", "html", "css", "js" ];  
$.inArray("js", arr);  //返回 3,
Copy after login

If it is not included in the array, it returns -1;

Related introduction:

jQuery is a JavaScript function library.

The jQuery library includes the following features:

  • HTML element selection

  • HTML element manipulation

  • CSS Operation

  • HTML Event Function

  • JavaScript Special Effects and Animation

  • HTML DOM traversal and modification

  • AJAX

  • Utilities

Recommended: "jquery video Tutorial

The above is the detailed content of How to determine whether a jquery array contains an element. For more information, please follow other related articles on the PHP Chinese website!

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