Copy Current URL to Clipboard Jquery

In this post I a simple Jquery code to copy the current URL to the clipboard. Here I make a simple button.

Button

 <a href="javascript:;" type="button" onclick="Copy();">Copy URL</a>

JQuery code

You can create a temporary DOM element to hold the URL.

    function Copy() {
            var dummy = document.createElement('input'),
            text = window.location.href;
            document.body.appendChild(dummy);
            dummy.value = text;
            dummy.select();
            document.execCommand('copy');
            document.body.removeChild(dummy);
        }