The insertAfter method
The insertAfter method adds text after the given element. There is also a after method that works in a similar way.
Syntax
Insert text after an element:
$(text).insertAfter(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 after the given paragraph:
<p id="test">paragraph indent indention indentation indenture rubric</p>
$('<p>!!!</p>').insertAfter('#test');
HTML the code will look like this:
<p id="test">paragraph indent indention indentation indenture rubric</p><p>!!!</p>
See also
-
method
after,
which adds text after the given element -
methods
insertBefore,appendTo⁅/ c⁆, ⁅c href="/en/javascript/lib/jquery/manual/prependTo/"⁆prependTo,
allowing you to add content to a specific location on a page -
method
clone,
which creates copies of the selected elements