I currently have a onclick even on a div as follow
function copyToClipboard(e) {
var textBox = document.getElementById(e.id);
console.log(textBox);
textBox.select();
document.execCommand("copy");
}
<div class="form-inline m-2">
<input type="text" class="form-inline" name="myvalue" id="{{ p.id }}" value="https://diccionarioespañol.com/significado/{{ p.nombre|lower }}/" readonly />
<button onclick="copyToClipboard(this)">