<div id="test">
<pre>
<b>Data1</b>
</pre>
<pre>Data2</pre>
</div>
<input type="button" value="Click Me" id="copypre">
<div id="result"></div>
<script>
document.getElementById("copypre").onclick = function () {
var result = document.getElementById("result");
var allpre = document.querySelectorAll("#test pre");
result.innerHTML = '';
for (var i = 0; i < allpre.length; i += 1) {
result.innerHTML += allpre[i].innerHTML + '<br>';
}
};
</script>