In this tutorial, you will learn how to add a copy paste button to Elementor Heading and Text Editor elements.
This button will allow users to either copy the text content of the elements, or copy their URL (both of which can be dynamic).
Here is a live example of what we will create in this tutorial:
Elementor Copy Paste Button Code
First, you will need this Elementor copy paste button code snippet on your page.
Copy paste the code below in an HTML element. Importantly, place the HTML element after ALL elements on which you want a copy paste button added. Lower on the page.
<script> /* Please login to get the code * The code will be for the Simple Elementor Copy Text And Link URL To Clipboard Button tutorial * Found at this URL https://element.how/elementor-copy-paste-clipboard-button/ */ </script>
Then, add the required class names to your elements
This will work on any element really, but is tested working on the Heading and Text Editor elements.
Go under Advanced > Custom CSS, and give the class name copyPaste to the elements where you want a copy paste button.
If you want them to copy paste the URL instead, give them both the class name copyPaste and copyPasteURL
With the copyPasteURL class name, the link of the heading will be copied to the clipboard, instead of its text content.
Adjusting the code
On the front end, you should see the copy paste buttons already.
To adjust their styles, go in the HTML element, and adjust the CSS variables you will find there.
Lower down, in the JavaScript, you can also adjust the SVG to your own icon if you prefer.
In the JavaScript is also where you will be able to edit the Copy and Copied! texts.
Finally, enjoy your Elementor Copy Paste Buttons!
I really hope you found this tutorial useful.
Cheers!
12 Responses
Your tutorials have always been SO incredibly helpful and when I spotted this on my hunt for a solution for a site I'm working on, I was thrilled it was you 🙂 Any chance there's a "paste" button tutorial to go with this?
Greetings Shannon!
I'm not certain about this... Paste where? What's the use case?
Cheers!
how to change custom url or text?
Enter the URL or text of your choice in your Heading element, and that's what will be copied.
For some reason, i can not have more than 1 copy paste button? I have repeated the HTML code block and applied CSS class "copyPaste" to 3 Heading elements, but the button only appears once? Any ideas why?
Thanks
Solved, don't repeat the HTML block 🙂
That's right! The code is needed only one time on the page, even if you have many copy paste elements.
Hello, thanks for this tutorial. Do you think it is possible to make the copy button works in a Pop Up?
Greetings!
Yes I think it should work. Add the HTML element IN the popup also.
Let me know.
Cheers!
Thanks. I did that, but the button is then not clickable. My question was whether there is any way to make it work.
Greetings!
To make it work in a popup, be certain to add the HTML element in the popup.
Then, delete these two lines:
if (window.ElementorCopyPasteEnabled) return;
window.ElementorCopyPasteEnabled = true;
And change this line:
const copyPasteElements = document.querySelectorAll('.copyPaste');
to this instead:
const copyPasteElements = document.querySelectorAll('.elementor-popup-modal .copyPaste');
Cheers!
Thank you very much, everything worked!