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.

New on Educative
Learn any Language for FREE all September 🎉
For the entire month of September, get unlimited access to our entire catalog of beginner coding resources.
🎁 G i v e a w a y
30 Days of Code
Complete Educative’s daily coding challenge every day in September, and win exciting Prizes.

Free Resources