<div id="code">foo</div> <div id="copy">bar</div> <script> var code = document.getElementById('code'); var copy = document.getElementById('copy') copy.innerHTML = code.innerHTML; </script>