jQuery is() Metode
Voorbeeld
As die ouer van <p> 'n <div>-element is, waarsku 'n paar teks:
if ($("p").parent().is("div")) {
alert("Parent of p is div");
}
Definisie en gebruik
Die is() metode kontroleer of een van die geselekteerde elemente by die selectorElement pas .
Sintaksis
$(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.
|