Click button to copy text to clipboard
This is something that I use a lot and thought you might find it useful. In the video I explain how it’s used. And further down this page you will find the Javascript code to put on the page to make it work.
Naming for the data attributes
| Data Attribute Name | Element to put it on |
|---|---|
| data-copy-text | Text element that you want to copy to clipboard. |
| data-copy-button | Button or image you want to have as the clickable item to run the copy script. |
| data-copy-message | A blank text element that will display the confirmation that it was copied. |
Get the code
Copy the javascript below and paste it into a code element in the javascript box. Do not forget to clear out the HTML box, and to approve running the code. The Data Attributes are as follows:
document.querySelector('[data-copy-button]').addEventListener('click', function() {
const text = document.querySelector('[data-copy-text]').innerText;
const message = document.querySelector('[data-copy-message]');
navigator.clipboard.writeText(text).then(() => {
message.innerText = "Copied to clipboard!";
}).catch(() => {
message.innerText = "Failed to copy";
});
setTimeout(() => {
message.innerText = "";
}, 2000); // Message disappears after 2 seconds
});
Fixing the shortcuts in Bricks Builder 2.0 RC
I take a look at the good and bad of the new Bricks Builder Release Candidate. While it is not…
Add a scroll image on mouse over
This is a cool feature that I stole from the Bricks template back end. In the video I show you…
Try Core Framework in Bricks Builder before buying.
In this video I show you how you can set up bricks to work with the free version of Core…
Adding ribbons in Bricks without writing CSS
If you're not a fan of writing CSS, you'll be happy to know that creating eye-catching ribbons in Bricks Builder…
Free framework for Bricks & Advanced Themer
I’m excited to introduce the Bricks Bits Framework, a free, lightweight framework designed to simplify your workflow by covering 99%…
10X the power of Advanced Themer for Bricks Builder
Have you ever been working on an element and feel a little lost on what is going on with its'…




