Fork me on GitHub

jQuery - Copy to clipboard plugin

Easy way to Copy text from any type of element.

Data-clipboard-text example

Add "data-clipboard-text" to anny element, click on it will execute the copy command on text with attribute value.

You can try it here.

Data-clipboard-target example

Add "data-clipboard-target" to anny element, click on it will execute the copy command. As a value use jQuery selector. Targeted element's value will be copied.



You can try it here.

Raw code example

Or you can just use jQuery selector to execute copy command on element's value/text.

    $('.button').click(function(){
        $(this).CopyToClipboard();
    });
                

You can try it here.