More then 1 copy to clipboard Button

Hi, i manage to do 1 copy button. The problem now how do i make another “copybutton2” with “texttocopy2”. I have tried it but my problem is both button is not functional correctly.

import wixWindow from 'wix-window';

$w.onReady(() => {
    $w("#copybutton1").onClick(() => {

         let textMessage = $w("#texttocopy1").text;

        wixWindow.copyToClipboard(textMessage)
             .then(() => {
                $w("#copybutton1").disable();
                $w("#copybutton1").label = 'Copied!';
                
                returnToDefault();

             })
     })
});

//Add a function to enable button and change the label after 1 second

function returnToDefault() {
    if ($w("#copybutton1").disable()) {
        setTimeout(function () {
            $w("#copybutton1").enable();
            $w("#copybutton1").label = 'Copy Text';
         }, 1000)
     }
}

1 Like

same situation here

It is now available on Wix App Market for free: https://www.wix.com/app-market/clip-copy-to-clipboard-button