<!DOCTYPE html>
<html lang="en-US">
<head>
<style>
p{
color:red;
}
</style>
</head>
<body>
<button onclick="myTrue()">True</button>
<button onclick="myFalse()">False</button>
<p>I'm paragraph</p>
<script>
var x = document.getElementsByTagName("p")[0];
function myTrue(){
var dup = x.cloneNode(true);
document.body.appendChild(dup);
}
function myFalse(){
var dup = x.cloneNode(false); //Clone only node, not text
var textnode = document.createTextNode("I'm also a paragraph");
dup.appendChild(textnode);
document.body.appendChild(dup);
}
</script> </body>
</html>