s

jquery copy to clipboard edit button Edit

author
Murugan Andezuthu Dharmaratnam | calendar 23 September 2020 | 2483

There is no option to copy text directly to the clipboard. The sample code below will help to copy text to the clipboard.

Script

function copyToClipboard(text) {
       var $temp = $("<input>");
       $("body").append($temp);
       $temp.val(text).select();
       document.execCommand("copy");
       $temp.remove();
}
           
                    

you can pass the text as a parameter to the copyToClipboard function and the text will get copied to the clipboard.