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.
  • Its can accept following values: HTML elements, jQuery objects and DOM elements.


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


  • 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>  

Try it

JS Bin on jsbin.com

Content Protection by DMCA.com
Please Share