I want to copy the HTML code by clicking on the button using javascript.
 <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        #data {
            background: #eee;
            width: 300px;
            padding: 13px;
            text-align: center;
            font-family: arial;
        }
    </style>
</head>
<body>
    <button type="button" onclick="copyToClipboard('data')">Copy </button>
    <textarea id="data" name="data">
<p>I Want to copy this html code1.</p>
<p>I Want to copy this html code2.</p>
</textarea>
    <script src="doc/jquery.min.js"></script>
    <script src="doc/clipboard.min.js"></script>
    <script>
        window.copyToClipboard = function(elementId) {
            var aux = document.getElementById(elementId);
            aux.select();
            document.execCommand("copy");
        }
    </script>
</body>
</html>
I try this code, but it shows the code only, and I want it to show the preview of the HTML code.like this
So how can I copy HTML code from the browser by clicking on the button?
I Want to copy this html code1.
I Want to copy this html code2.