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
-
method
append
,
which adds text to the end of an element -
pseudo-element
after
,
which adds text to the end of an element using CSS -
methods
prependTo
,insertBefore⁅/ c⁆, ⁅c href="/en/javascript/lib/jquery/manual/insertAfter/"⁆insertAfter
,
allowing you to add content to a specific location