In jQuery, the after()
method is used to insert content after the selected elements in the jQuery collection.
(a).after(b)
a
: the element after the new element will be added.b
: the content to be added.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.