Clipboard.js cannot copy the content to the clipboard

 <span class="confirmButton" data-clipboard-text="Test Text"></span>
    function copyToClipBoard() {
        var clipboard = new Clipboard(".confirmButton");
        console.log(clipboard);
        clipboard.on("success", function (e) {
           alert("1");
        });

        clipboard.on("error", function (e) {
            alert("2");
        });
    }

there is no alert output, only console output.

Mar.13,2021

if you are in a chrome browser, it may be because flash, is disabled. Take a look at

clipboard.png

is there a prompt to disable flash in the browser URL


resolved. The button that triggered the copy event was not clicked.

Menu