I'm trying to make the clipboard.js change the copy button from "COPY" to "COPIED" after the click without losing the function it has that selects the target code.
Would anyone know what I should do?
! function() {
for (var a = document.getElementsByTagName("pre"), b = document.getElementById("paste-content"), c = 0; c < a.length; c++) {
var d = a[c].children[0].className.indexOf("language-");
if (0 === d) {
var e = document.createElement("button");
e.className = "copy-button", e.textContent = "COPY", a[c].appendChild(e)
}
}
var f = new Clipboard(".copy-button", {
target: function(a) {
return a.previousElementSibling
}
})
}();
<script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.7.1/clipboard.min.js"></script><preclass="input button border"><code class="language-less" id="dialog_coupon_code_1">CODE 1</code></pre>
<pre class="input button border"><code class="language-less" id="dialog_coupon_code_2">CODE 2</code></pre>
<pre class="input button border"><code class="language-less" id="dialog_coupon_code_3">CODE 3</code></pre>