Basic Methods and Properties
These are the basic methods and properties of jQuery objects. They donât alter the selection or the selected elements in any way, but they allow you to query and iterate over the set of selected elements. See the section Queries and Query Results for details.
context
The context, or root element, under which the selection was made. This is the second argument to
$()
or the Document object.each(
f
(idx
,elt
))Invokes
f
once as a method of each selected element. Stops iterating if the function returnsfalse
. Returns the jQuery object on which it was invoked.get(
idx
):eltget():array
Return the selected element at the specified index in the jQuery object. You can also use regular square bracket array indexing. With no arguments,
get()
is a synonym fortoArray()
.index():int
index(
sel
):intindex(
elt
):intWith no argument, return the index of the first selected element among its siblings. With a selector argument, return the index of the first selected element within the set of elements that match the selector
sel
, or -1 if it is not found. With an element argument, return the index ofelt
in the selected elements, or -1 if it is not found.is(
sel
):booleanReturns
true
if at least one of the selected elements also matchessel
.length
The number of selected elements.
map(
f
(idx
,elt
)):jQueryInvokes
f
once as a method of each selected element, and returns a new jQuery object that holds the returned values, withnull
andundefined
values omitted and array values flattened.selector ...
Get jQuery Pocket Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.