15 of 119 menu

The prependTo method

The prependTo method adds text to the beginning of an element. There is also a prepend method that works in a similar way.

Syntax

Insert text at the beginning of an element:

$(text).prependTo(selector);

The content can be not only plain text, but also a DOM element, selector, array of elements, string or jQuery object.

Example

Let's insert text with tags at the beginning of the given paragraph:

<p id="test">paragraph indent indention indentation indenture rubric</p> $('<b>!!!</b>').prependTo('#test');

Result of code execution:

<p id="test"><b>!!!</b>paragraph indent indention indentation indenture rubric</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