Something I've worked with often but never had a chance to create was a button to send text to a user's clipboard. One of those things that's easy to take for granted until you realize you don't exactly understand how they work.

While working on the Lead Deals website, I realized I needed an easy way to copy some text inputs when entering info, and realized I needed one.

A handy StackOverflow answer indicated there were a number of options, with a number of people arguing for different techniques. Among the replies I found an answer I really liked:

function copyToClipboard(text) {
    if (window.clipboardData && window.clipboardData.setData) {
        // IE specific code path to prevent textarea being shown while dialog is visible.
        return clipboardData.setData("Text", text); 

    } else if (document.queryCommandSupported && document.queryCommandSupported("copy")) {
        var textarea = document.createElement("textarea");
        textarea.textContent = text;
        textarea.style.position = "fixed";  // Prevent scrolling to bottom of page in MS Edge.
        document.body.appendChild(textarea);
        textarea.select();
        try {
            return document.execCommand("copy");  // Security exception may be thrown by some browsers.
        } catch (ex) {
            console.warn("Copy to clipboard failed.", ex);
            return false;
        } finally {
            document.body.removeChild(textarea);
        }
    }
}

It seemed clean and cross-browser compatible. It was also pure JavaScript, which has been good as I attempt to ween myself off of jQuery. Using some Bootstrap I was able to put it in this handy Pen:

See the Pen Copy Button by Jamie (@jamiebclark) on CodePen.