21 of 119 menu

The wrapAll method

The wrapAll method wraps all elements of a set in a single specified tag. If these elements are in different places, jQuery first places them next to each other, and then wraps them in the desired tag.

Syntax

The method parameter can be text (possibly with tags), a DOM element, or a jQuery object:

.wrapAll(what to wrap it with);

We can also use a function for each element:

.wrapAll(function(number in the set))

Example

Let's wrap paragraphs with class www in tag div:

<p class="www">text</p> <p class="www">text</p> <p class="www">text</p> <p>text</p> $('.www').wrapAll('<div></div>');

HTML the code will look like this:

<div> <p class="www">text</p> <p class="www">text</p> <p class="www">text</p> </div> <p>text</p>

See also

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