Home > Web Front-end > JS Tutorial > body text

Example of usage of is() method in jQuery_jquery

WBOY
Release: 2016-05-16 16:21:53
Original
1079 people have browsed it

The example in this article describes the usage of the is() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method uses parameters to check a collection of matching elements.
Returns true if at least one element matches the given parameter, otherwise returns false.

Grammar structure 1:

Copy code The code is as follows:
$(selector).is(expr)

Parameter list:
参数 描述
expr 字符串值,供匹配当前元素集合的选择器表达式。

Example code:

Copy code The code is as follows:






is() function-Script Home






  • div css area

  • jQuery Zone





The following code detects whether the parent element of the li element is ul, and returns true if it is, otherwise it returns false.

Grammar structure 2:

Parameter list:

参数 描述
element 用于匹配元素的DOM元素或者jQuery元素。

Example code:

Example 1:

Copy code The code is as follows:






is() function-Script Home






  • div css area

  • jQuery Zone





Example 2:

Copy code The code is as follows:






is() function-Script Home






  • div css area

  • jQuery Zone





문법 구조 3:

함수를 사용하여 요소 컬렉션을 반복합니다.
이 함수는 jQuery 컬렉션에 있는 요소의 인덱스인 매개변수 인덱스를 허용합니다. 함수에서 이는 현재 DOM 요소를 나타냅니다.

매개변수 목록:

参数 描述
function(index) 定义返回is()匹配值的函数。
index为当前元素在匹配元素集合中的索引值。

예제 코드:

코드 복사 코드는 다음과 같습니다.





is() 함수-스크립트 홈

Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template