$append
Insert content or DOM element to the end of element.
$append( element, node )
element [object]
The target element.property [object/string]
HTML string or DOM element.
Notes
Common function to update content on the page.
Example
HTML code
<div id="box_wrap"> <div class="box_item">box 1</div> <div class="box_item">box 2</div> <div class="box_item">box 3</div> </div> <button onclick="start_create()">Insert new box</button>
CSS code
#box_wrap {
width:300px;
font-size: 12px;
background: #eee;
border: 4px solid #333;
padding: 10px;
}
.box_item {
width: 100px;
height: 50px;
font-size: 12px;
background: #5599bb;
padding: 10px;
margin: 10px 0;
}
#new_box {
background: red !important;
}JavaScript code
function start_create()
{
$append( $("box_wrap"), $new( "div", {
"className": "box_item",
"id": "new_box",
"title": "This is a new box",
"html": "This is a new box"
}));
}
Demonstration
box 1
box 2
box 3