48 of 119 menu

The prevAll method

The prevAll method returns all elements that come before the given one within a single parent.

Syntax

Getting all neighbors above:

$(selector).prevAll();

You can also filter neighbors by a given selector:

$(element).prevAll(selector);

Example

Let's find the element #test and set the text '!' to all its neighbors above using the html method:

<p>outside</p> <div> <p>inside</p> <p>inside</p> <p id="test">inside</p> <p>inside</p> <p>inside</p> </div> <p>outside</p> $('#test').prevAll().html('!');

HTML the code will look like this:

<p>outside</p> <div> <p>!</p> <p>!</p> <p id="test">inside</p> <p>inside</p> <p>inside</p> </div> <p>outside</p>

See also

  • method nextAll,
    which returns elements that are after the given one within the same parent
  • method prev,
    which allows the element's neighbor to be above
  • method prevUntil,
    which returns the elements that come before the given one
  • method siblings,
    which allows you to get the neighbors of an element within one parent
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