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

How to determine whether a jquery array contains an element

藏色散人
藏色散人Original
2021-02-01 10:01:215605browse

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,

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!

Statement:
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