728x90
SMALL
#jquery
#clone()
.clone()
.clone() clones the selected element.
grammar
.clone( [withDataAndEvents ] )
for example
$( '.ab' ).clone().appendTo( 'h1' );
will duplicate the element with ab as the class value and put it in the h1 element.
example
Duplicate the span element and place it inside the h1 tag.
<!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' ).clone().appendTo( 'h1' );
} );
</script>
</head>
<body>
<h1></h1>
<p><span>Lorem ipsum dolor.</span></p>
</body>
</html>
Here is the rendered result:
<h1><span>Lorem ipsum dolor.</span></h1>
<p><span>Lorem ipsum dolor.</span></p>
728x90
LIST