append():
- In JQuery, append() method is used to insert the data or content at the end of the element as child element specify by the parameter.
- Syntax:
$(selector).append(content,function(index,html))
Here, we have passed two parameters in the method:
The first one is the content which is a required field with values such as HTML elements, jQuery objects and DOM elements.
The second one is the function(index,html) which is a optional field. It returns the content to insert.
Example: Suppose we have the following HTML code
<div class='a'>
<div class='b'>b</div>
</div>
Suppose we want to insert div c in the div a at last place. For this we will use append() method.
$("div.a").append("<div class='c'>C</div>");
The HTML code now look like
<div class='a'>
<div class='b'>b
<div class='c'>C /<----this will be placed here.
</div>
0 Comment(s)