Home  >  jQuery

Example of .after() in jQuery

February 18, 2013
.after() in jQuery inserts the element just after the element on which .after() is being called. .after() searches all the those DOM element on which .after() has been called and adds the content specified by .after(). Lets understand by code.
<p> Hellow</p>
$('p').after("<p> World</p>");
 
In above code .after() searches for p element. And adds the content defined in .after() argument. If p is more than one then to all places of p will be added with the content specified by .after(). See the full code.
<!DOCTYPE html>
<html>
	<head>
	<script src="http://code.jquery.com/jquery-latest.js"></script>
	</head>
<body>
	<p> Hellow</p>
	<p> Whole</p>
	<script>
	$('p').after("<p> World</p>");
	</script>
</body>
</html>
 
Output

Hellow

World

Whole

World

FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us