The appendTo() method inserts HTML elements at the end of the selected elements and To insert HTML elements at the beginning of the selected elements, use the prependTo() method.
Method Syntax:
|
|
|
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("button").click(function(){
$("<span>Hello World! how are you ? </span>").appendTo("p");
});
});
</script>
</head>
<body>
<p>This is another paragraph.</p>
</html>
|