jQuery after()

jQuery after() method is used to insert the specified content after each element in the set of matched elements.

jQuery after() inserts content after the selected elements.


$(selector).after(content, function(index))


  • Content is a compulsory parameter of jQuery after() method, as it specifies the content to insert after the selected element.
  • It can accept the following values: HTML elements, jQuery objects, and DOM elements.


  • It is an optional parameter.
  • The function parameter is used to return the inserted content.


  • The index is an argument passed within the function.
  • It is used to give an index position to an element in the set.


<!DOCTYPE html>
<!DOCTYPE html>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
$("p").after("<p>How are you?</p>");
<button>Click me</button>
Please follow and like us:
Content Protection by DMCA.com