Several interfaces exist to assist you if you need to test specifics about the number of elements that match a given element specification.
#all
Use #all
to retrieve all matched elements:
#children
Use #children
to access immediate child elements of the current element. Return an empty array if no children present.
Pass text: true
to also include dangling text (default: false
):
#[]
Use #[]
to index a specific element from a matching set. Note that indexing starts at 1
, not 0
, so the first element in a set is [1]
.
You can also use #first
or #last
if you prefer:
#size
Use #size
to verify the length of a set of matched elements: