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 to Code
Learn any Language as a beginner
Develop a human edge in an AI powered world and learn to code with AI from our beginner friendly catalog
🏆 Leaderboard
Daily Coding Challenge
Solve a new coding challenge every day and climb the leaderboard

Free Resources