jQuery insertAfter() Method

The jQuery insertAfter() method can be used to insert the content after the selected content. You have to specify the selected element as the parameter of the method.

jQuery insertAfter() Method

Syntax

The syntax of this method is given below:-

Syntax
$(content).insertAfter(selector)

Description of the Parameters

The description of these parameters is given below.

Parameter Name Description
selector Specify the element to select and add content after it. You have to use tag name, class name, or id of the elements to select. It is a required field.
content Specify the content to insert after the selected element. It is a required field.

jQuery insertAfter() Method to Insert Content

If you want to insert content after the selected element, you have to use the example as given below. The content can be specified first and after that, you have to use the method and pass element as a parameter to select.

Example

Test it Live

Output

This is my paragraph.


The above example contains the paragraph text and the button element. You have to click the button given above to insert content b element after the paragraph.

You may also like to read

I hope you like this tutorial on jQuery insertAfter() method. If you have any queries regarding the tutorial, please comment below.

References