Question for kolasim!How to configure the copy button correctly?
Author: Дмитрий ТулуповHello. If anyone knows the answer to my question, please let me know.
I am sure that KolAsim, respected here, who has repeatedly helped me with codes, will easily help in this matter.
In the footer of the site 5958.ru, I installed a button, by clicking on which the guest of the site can copy the bank card number.
I found on the Internet (https://jsfiddle.net/webdevhelp/bso96npm/5/) a more suitable option for me and installed the button. But unfortunately I could not install the script, since I have never done this on the constructor. I made several attempts, but I did not achieve a working effect. I installed the button itself with the text using the HTML module.
I also clarified at the hosting that their system supports JavaScript + jQuery.
Please give detailed instructions for installing the script!
If you have an alternative copy button, please post it here.
Sincerely,
Dmitriy.
... in the HTML Code Object paste all this code:
<div id="text">123 456 789</div>
<button id="copy">▲ Copy the text-number </button>
<script>
$('#copy').click(function() { var $temp = $("<input>"); $("body").append($temp); $temp.val($('#text').text()).select(); document.execCommand("copy"); $temp.remove(); $(this).text('copied text!'); });
</script>
.
ciao
.
Author
May God grant you good health, long life and success in your affairs!