From jQuery JavaScript Library
« Back to Manipulation
appendTo( content )
Append all of the matched elements to another, specified, set of elements.
This operation is, essentially, the reverse of doing a regular $(A).
append(B), in that instead of appending B to A, you're appending A to B.
Arguments:| content | String | |
|---|
| target to which the content will be appended. |
Examples:| Name | Type |
Appends all spans to the element with the ID "foo"
$("span").appendTo("#foo"); // check append() examples
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script src="../jquery-latest.js"></script>
<script>
$(document).ready(function(){
$("span").appendTo("#foo"); // check append() examples
});
</script>
<style>#foo { background:yellow; }</style>
</head>
<body>
<span>I have nothing more to say... </span>
<div id="foo">FOO! </div>
</body>
</html>