I am trying to add button to copy simple text string but without success.
I've successfully used this JavaScript code which doesn't require any new HTML elements:
var text = ...;
var listener = function(ev) {
ev.clipboardData.setData("text/plain", text);
ev.preventDefault();
};
document.addEventListener("copy", listener);
document.execCommand("copy");
document.removeEventListener("copy", listener);