0

hello every one i have used the below code but not working i want to copy xmp date with button please help

<xmp id="content"style="background-color: #eff0f1; color: #7d2727; font-size: 16px; font-family: Arial, Helvetica, sans-serif;">

44444jjjjj
</xmp>
        <input type="button" id="copyID" value="Copy" />
        <script type="text/javascript">
               var button = document.getElementById("copyID"),
            xmp = document.getElementById("content");

        button.addEventListener("click", function(event) {
            event.preventDefault();
            xmp.select();
            document.execCommand("copy");
        });
    </script>
</body>
</html>
  • seems a duplicate of : https://stackoverflow.com/questions/985272/selecting-text-in-an-element-akin-to-highlighting-with-your-mouse because https://developer.mozilla.org/en-US/docs/Web/API/HTMLInputElement/select – G-Cyrillus Sep 14 '20 at 19:33
  • correct my above code – jabar kahn Sep 15 '20 at 07:34

0 Answers0