I have some content copied on the clipboard. I'd like that to get pasted as an input text when I press a button called PASTE . I don't know how to do this using CSS or js.
I've tried this:
<script type="text/javascript">
function copiarAlPortapapeles(id_elemento) {
var aux = document.createElement("input");
aux.setAttribute("value", document.getElementById(id_elemento).innerHTML);
document.body.appendChild(aux);
aux.select();
document.execCommand("copy");
document.body.removeChild(aux);
}
</script>
<p id="p1">hola como estas</p>
<button onclick="copiarAlPortapapeles('p1')">Copiar P1</button>
<br/><br/>
<input type="text" placeholder="Pega aquí para probar" />
but it just works to copy content to the clipboard, I cannot find any solution how to do.
thanks for help