insertAfter() method in jQuery

insertAfter() in jQuery

This method is used to insert every element after the target in the set of matched elements.

Syntax 1

$(selector).insertAfter(targetSelector)

  • targetSelector - A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element specified in this parameter.
Syntax 2

$(content).insertAfter(targetSelector)

  • targetSelector - A selector, element, array of elements, HTML string, or jQuery object; the matched set of elements will be inserted before the element specified in this parameter.
  • content - html string or text

Example 1

Try Yourself

Example 2

Try Yourself