How to use HTML insertAfter Method in JQuery
This article describe about HTML insertAfter Method in JQuery.
HTML insertAfter() method in jQuery
insertAfter() method is used to insert element existing element or HTML markup after the selected element.
If we use existing method then selected element will me moved our current position and show the new location.
Syntax
$(content).insertAfter(selector)
|
Example
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function ()
{
$("button").click(function ()
{
$("<span>Hello world!</span>").insertAfter("p");
});
});
</script>
</head>
<body>
<p>This is a JQuery.</p>
<p>This is .Netheaven.</p>
<button>Insert span element after each p element</button>
</body>
</html>
|
Output1
Output2
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here