Introduction:

In this article we will explain how to add specified content after the selected element.in jQuery or What is after() method in jQuery or why use after() method in jQuery with example.

Description:

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

Let’s see, Example of jQuery after() method:

<!DOCTYPE html>
<html>
<head>
    <title>Example of jQuery after() method</title>
    <script type="text/javascript" src="https://code.jquery.com/jquery-1.10.2.js"></script>
    <script>
        $(document).ready(function () {
            $("button").click(function () {
                $("p").after("<b>Hello sqltutorialspoint.com</b>");
            });
        });
    </script>
</head>
<body>
    <div>
        <button>Add content after each paragraph element</button>
    </div>
    <div>
        <p style="width:300px;">This is a Articles website.</p>
        <p style="width:300px;">This is a Forums institute.</p>
    </div>
</body>
</html>


 Let's check live example

0 comments


Leave a comment

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

You may also like