Sunday, 16 July 2017

Copy to Clipboard

Copying text to the clipboard shouldn't be hard. A very simple example is as given below : 

<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.3.min.js" ></script>
<script type="text/javascript">
    $(document).ready(function () {
        $("#btnCopy").click(function () {
            $("#txtData").select();
            document.execCommand("Copy");
        });
    })
</script>


<input type="text" id="txtData" />
<input type="button" value="Copy" id="btnCopy" />

No comments:

Post a Comment