728x90
SMALL
#jQuery
#appendTo()
.appendTo()
.appendTo() puts the selected element into another element.
grammar
.appendTo( target )
for example
$( 'p' ).appendTo( 'blockquote' );
moves the p element to the blockquote element.
example
Move the span element with abc as the class value to the h1 element.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery</title>
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
$( document ).ready( function() {
$( 'span.abc' ).appendTo( 'h1' );
} );
</script>
</head>
<body>
<h1>Lorem Ipsum Dolor</h1>
<span class="abc">Consectetur adipiscing elit.</span>
<p>Aenean nec mollis nulla.</p>
</body>
</html>
Here is the rendered result:
<h1>Lorem Ipsum Dolor<span class="abc">Consectetur adipiscing elit.</span></h1>
<p>Aenean nec mollis nulla.</p>
728x90
LIST