Home >>jQuery Tutorial >jQuery appendTo() Method
jQuery appendTo() method is used to inserts HTML elements at the end of the selected elements.
Syntax:$(content).appendTo(selector)
Parameter | Description |
---|---|
content | It is a Required parameter and is used to insert the Specifies the content (must contain HTML tags). |
selector | It is Required parameter used to Specifies to append the content of selected element |
<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(){
$("<span>Hello phptpoint!</span>").appendTo(".txt1");
});
});
</script>
</head>
<body>
<button class="btn1">click me to insert element</button>
<p class="txt1">This is a paragraph...</p>
<p class="txt1">PHPTPOINT...</p>
</body>
</html>
This is a paragraph...
PHPTPOINT...