Home >>jQuery Tutorial >jQuery after() Method
jQuery after() method in jQuery is used to inserts specified content afterselecting the elements.
Syntax:$(selector).after(content,function(index))
Parameter | Description |
---|---|
content |
It is a Required parameter used to insert the specifies content (can contain HTML tags)
Possible values:
|
function(index) |
It is used to returns the specifies content to insert
|
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".btn1").click(function(){
$(".txt").after("<p>PHPTPOINT</p>");
});
});
</script>
</head>
<body>
<button class="btn1">click to insert content</button>
<p class="txt">This is a Phptpoint.</p>
<p class="txt">learn here</p>
</body>
</html>
This is a Phptpoint.
learn here