jQuery clone()

The clone() method makes a copy of selected elements, including child nodes, text, and attributes. The .clone() method performs a deep copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes.

Syntax:

$(selector).clone(true|false)

Example:1

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $("p").clone().appendTo("body");
    });
});
</script>
</head>
<body>
<p>This is a paragraph one.....</p>
<p>This is another paragraph two </p>
<button>Click here to Clone all p elements, and append them to the body element</button>
</body>
</html>