The last method

The last method selects the last element among those already found.

Syntax

javascript.last();

Example

Let's find all the paragraphs, then select the last one from those found and assign it the text '!':

html<p>text</p>
<p>text</p>
<p>text</p>
javascript$('p').last().text('!');

HTML the code will look like this:

html<p>text</p>
<p>text</p>
<p>!</p>

See also

  • method first,
    which receives the first element
  • method eq,
    which gets c element with a certain number