# copy-the-code/3.8.2/assets/js/copy-inline.js

Copy Anything to Clipboard for WordPress – Copy Button, Copy Text &amp; Copy Code, version 3.8.2. 48 lines.

- Page: https://pluginprobe.com/plugins/copy-the-code/3.8.2/code/assets/js/copy-inline.js
- Raw: https://pluginprobe.com/plugins/copy-the-code/3.8.2/raw/assets/js/copy-inline.js
- Modified: 2024-05-29T19:37:48+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/copy-the-code/3.8.2/code/assets/js/copy-inline.js#L10-L20`.

```javascript
(function ($) {
    const CTCInline = {

        /**
         * Init
         */
        init: function () {
            this._bind();
        },

        /**
         * Binds events
         */
        _bind: function () {
            $( document ).on( 'click', '.ctc-inline-copy', this.doCopy );
        },

        /**
         * Do Copy to Clipboard
         */
        doCopy: function (event) {
            event.preventDefault();

            const self = $( this )
            let text = self.find( '.ctc-inline-copy-textarea' ).val() || ''

            // Remove first and last new line.
            text = $.trim(text);

            // Copy to clipboard.
            CTCWP.copy(text);

            // Copied!
            self.addClass('copied');
            setTimeout(function () {
                self.removeClass('copied');
            }, 1000);
        }
    };

    /**
     * Initialization
     */
    $(function () {
        CTCInline.init();
    });

})(jQuery);
```
