What is the after() method in jQuery?

In jQuery, the after() method is used to insert content after the selected elements in the jQuery collection.

Syntax

(a).after(b)

Parameters

  • a: the element after the new element will be added.
  • b: the content to be added.

Code

In the code below, the text “Educative rocks!” gets added after the h1 tag, which happens to be "Learn about the after() method in jQuery".

This happens once the “Add” button is clicked.

Free Resources