Home >>jQuery Tutorial >jQuery append() Method
jQuery append() method in jQuery is used to inserts specified content at the end of the selected elements.
Syntax:$(selector).append(content,function(index,html))
Parameter | Description |
---|---|
content |
It is a Required parameter used to insert the specifies content (can contain HTML tags)
Possible values:
|
function(index,html) |
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(){
$(".txt1").append(" <b>Append text</b>.");
});
$("#btn2").click(function(){
$(".list").append("<li>Append item</li>");
});
});
</script>
</head>
<body>
<p class="txt1">Phptpoint</p>
<p class="txt1">learn here</p>
<ol class="list">
<li>List item 1</li>
<li>List item 2</li>
</ol>
<button id="btn1">Append text</button>
<button id="btn2">Append list</button>
</body>
</html>
Phptpoint
learn here