13 of 119 menu

The appendTo method

The appendTo method adds text to the end of an element. There is also a append method that works in a similar way.

Syntax

Insert text at the end of an element:

$(text).appendTo(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 end of the given paragraph:

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

Result of code execution:

<p id="test">paragraph<and>!!!</b></p>

See also

enru