jQuery is() 메서드

❮ jQuery 탐색 방법

예시

<p>의 부모가 <div> 요소인 경우 일부 텍스트에 경고를 표시합니다.

if ($("p").parent().is("div")) {
  alert("Parent of p is div");
}

정의 및 사용

is() 메서드는 선택한 요소 중 하나가 selectorElement 와 일치하는지 확인합니다 .


통사론

$(selector).is(selectorElement,function(index,element))

Parameter Description
selectorElement Required. Specifies a selector expression, element or a jQuery object to match the current set of elements against. Returns true if there is at least one match from the given argument, and false if not.
function(index,element)

Optional. Specifies a function to run for the group of selected elements.

  • index - the index position of the element
  • element - the current element (the "this" selector can also be used)

❮ jQuery 탐색 방법