jQuery after() and insertAfter() example

In this post,  we are going to see jQuery after and insertAfter methods.

Both do the same task, insert text or html after every selected elements but syntax is quite different.

Syntax for after():

$("selectors").after("element to be inserted") ;
Example :
$("div").after("

inserting using after

");

Syntax for insertAfter() :

$("element to be inserted") .insertAfter("div");
Example:
$("

inserting using insertAfter

").insertAfter("div");
Let’s understand with the help of example:


  Jquery after and insertAfter example example 
  

Jquery after and insertAfter example example

Hello world from java2blog!!!!
Welcome to JQuery.

Live demo: Jquery after and insertAfter example example on jsbin.com

[social_share share_on="facebook,twitter,linkedin,whatsapp"][post_navigator in_same_term="true"]

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to our newletter

Get quality tutorials to your inbox. Subscribe now.