Hello Readers,
jquery after() method is used to insert the given content after the specified each selected content or elements.
Syntax :
$(selector).after(content,function(index))
content : this is required parameter which specifies the content to insert.
function : this function is used to return the HTML after the content insert.
Code Example :
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("p").after("<p>Hello world!</p>");
});
});
</script>
</head>
<body>
<button>Insert content after each p element</button>
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>
</body>
</html>
In the above code use the after() method and insert the HTML content after the each
tag in jquery.
0 Comment(s)