jQuery Tutorial Tutorials - jQuery .insertAfter() method

jQuery .insertAfter() method

The .insertAfter() method in jQuery is used to insert each matched element after the target (outside).

jQuery .insertAfter() method Syntax

.insertAfter(target)

The matched elements will be inserted after target.

jQuery .insertAfter() method example

example

Insert 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>

Try now

Date:2019-08-24 17:53:58 From:www.Lautturi.com author:Lautturi