title: How to clone the contents of a div into another div with JavaScript?
body: <p>I want to clone the images of the div <code>leftSide</code> into the div <code>rightSide</code>. On each click on the body the images on the left div should be cloned into the right div. But I can't get the result with the code I'm doing. Is there any mistake in my code? I want to use JavaScript. </p>
  
  <p>Here's my code:</p>
  
  <pre><code>        var theLeftSide = document.getElementById("leftSide");  
          var width = 500; var height = 500;
          top_position = 0; var left_position = 0,
          var numberOfFaces = 5;
          var theRightSide = document.getElementById("rightSide");
          var leftSideImages = theLeftSide.cloneNode(true);
          document.getElementById("rightSide").appendChild(leftSideImages);
  
  
              for (var i = 0; i &lt; 5; i++) {
              createElement(i);   
              numberOfFaces += 5;
  
          function createElement() {
              var image = document.createElement('img');
              image.src = "smile.png";
              image.style.position = 'absolute';
              image.style.top = top_position + "px";
              image.style.left = left_position + "px";
              theLeftSide.appendChild(image);
              top_position = Math.random() *   500 ;
              left_position = Math.random() *  500 ;  
  </code></pre>