The get method

The get method gets a set of elements corresponding to a jQuery object.

Syntax

This is how we get the entire set of elements as an array:

javascript.get();

You can specify a specific number of an element in a set and get it. The number can also have a negative value (then the count is made backwards from the last element):

javascript.get(number);

Example

Let's get the second paragraph using the get method, counting from 0:

html<p>text</p>
<p class="aaa">text</p>
<p>text</p>
<p>text</p>
javascriptalert( $('p').get(1) );

See also

  • method find,
    which searches for elements within those already found
  • method filter,
    which filters the elements in a set