jQuery DOM Manipulations - 2
jQuery DOM Manipulations - 2
Introduction & append
Hello,
In our examples so far, we have done an update or read operation for HTML DOM objects.
We will learn the insert operation with append() method.
Let's look at an example.
<button id="add">
Add New Item
</button>
<div id="target"></div>
<script>
/*
Listen for an element with
the add id click
*/
$('#add').click(function(){
/*
append '<p>This is the appended
text</p>' to #target element
*/
$("#target").append("<p>Appended text</p>");
})
</script>append
After running the above code, the append method will add the HTML (passed as argument) code at the end of the #test element.