• In this tutorial we will learn how to add specified content after the selected element. in jquery or What is insertAfter() method in jquery or why use insertAfter() method in jquery with example.

  • Description: 

The jQuery insertAfter() method is used to add specified content after the selected element. It is just like jQuery after() method. If you want to add content before the selected element, you should use jQuery before() method.

The jQuery after() and jQuery insertAfter() both methods are used to perform the same task of adding additional contents after the selected elements.


  • $(content).insertAfter(selector);

  • Example of jQuery insertAfter() method

Let's take an example to demonstrate jQuery insertAfter() Method.

<!DOCTYPE html>
    <script src=""></script>
        $(document).ready(function () {
            $("button").click(function () {                $("<span><b>Join</b></span>").insertAfter("p");
    <button>add span element after each p element</button>
    <p>This is a sql tutorials website.</p>
    <p>This is a sql tutorials institute.</p>


how to add text after the selected element in jquery

In above example when we click on button box "<p><b></b></p>"

after each of the paragraph.


I hope this article will help to you.


 Let's check live example

Leave a comment

Make sure you enter the (*) required information where indicated. HTML code is not allowed.

You may also like