66 of 119 menu

The end method

The end method returns the previous set of elements in the current method chain.

Syntax

.end();

Example

In the following example we will find all paragraphs, then select the paragraphs with class www from those found using filter and append the text '!' to the end of them using append, then go back to the previous set (which is the $('p') set) using end and append the text '?' to the end of them. It turns out that paragraphs with class www will have text '!?', and regular paragraphs will have text '?':

<p class="www">text</p> <p class="www">text</p> <p>text</p> <p>text</p> $('p').filter('.www').append('!').end().append('?');

HTML the code will look like this:

<p class="www">text!?</p> <p class="www">text!?</p> <p>text?</p> <p>text?</p>

See also

  • method add,
    which adds elements to a set
  • method addBack,
    which adds elements from the previous set to the current one
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline