Metoda jQuery is() .

❮ Metody procházení jQuery

Příklad

Pokud je nadřazeným prvkem <p> prvek <div>, upozorněte na text:

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

Definice a použití

Metoda is() kontroluje, zda jeden z vybraných prvků odpovídá selectorElement .


Syntax

$(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)

❮ Metody procházení jQuery