.insertAfter()
methodThe .insertAfter()
method in jQuery is used to insert each matched element after the target (outside).
.insertAfter()
method Syntax.insertAfter(target)
The matched elements will be inserted after target
.
.insertAfter()
method exampleInsert HTML content after all paragraphs
HTML
<div class="container"> <p>Learn JavaScript</p> <p>Learn jQuery</p> </div>
jQuery
$("<p> Lautturi.com </p>").insertAfter("p");
Result
<div class="container"> <p>Learn JavaScript</p> <p> Lautturi.com </p> <p>Learn jQuery</p> <p> Lautturi.com </p> </div>