See the Pen Copy text to clipboard w/ JavaScript by levi (@velilevi) on CodePen.