Home  >  jQuery

Example of .appendTo() in jQuery

February 21, 2013
In jQuery, .appendTo() is the API that appends every matched elements with target element. .appendTo() can be called as
$("p").appendTo("#divid");
 
All the p, elements will be added in current stack with div with id "divid". Any DOM element can be used for .appendTo(). Find the example to use .appendTo
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<p>World!</p>
<div id="divid">Hellow</div>
<script>
$("p").appendTo("#divid");
</script>
</body>
</html>
 
Output
Hellow

World!

FIND MORE TUTORILAS






©2019 concretepage.com | Privacy Policy | Contact Us