Javatpoint Logo
Javatpoint Logo

jQuery insertAfter()

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

Difference between jQuery after() and insertAfter()

The main difference between after() and insertAfter is in syntax and placement of the content and target.

In after() method, target is the selected element and content is placed as an argument of the method.

In insertAfter() method, content is the selected element and target is placed as an argument of the method.

Note: If you want to insert HTML elements before the selected element, you should use the insertBefore() method.

Syntax:

Parameters of jQuery insertAfter() method

Parameter Description
Content It is a mandatory parameter. It specifies the content which you want to insert.
Selector It is also a mandatory parameter. It specifies the place where you insert the content.>

jQuery insertAfter() method example

Let's see an example of jQuery insertAfter() method.

Test it Now

Output:

This is a tutorial website.

This is a training institute.

Next TopicjQuery append()




Let's Work Together!

Javatpoint is passionate to offer better content to the world. Please mail your contribution to contribute@javatpoint.com. We will show your name and create your user profile. You can contribute the following things:
  • Article on Any Topic (which is not available on Javatpoint)
  • Your Interview Experience on Company
  • Company Interview Questions with Answers
  • Recruitment Process of Company
  • Programs, and Algorithm
  • Videos
  • Test Paper
  • Improve Article

Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials