0
I’m trying to copy content from a div to an input. I’ve been able to copy from one input to another or from one div to another, but I couldn’t get from one div to an input.
<div id="teste">
Exemplo
</div>
<input id="texto" />
What I got was :
<div id="teste">
Exemplo dasjkhd kdhasj khd askjh
</div>
<div id="texto"></div>
<script>// Elemento com o Texto
var elemento = document.getElementById('teste').innerHTML;
// Escrevendo em outro Elemento
var texto = document.getElementById('texto');
texto.innerHTML = "Texto Copiado: " + elemento;
</script>
input does not have property
innerHTML
, try using the propertyvalue
, by the way, put the type of input, text, for example– Ricardo Pontual
It worked, now would be able to update automatically without needing to update the page?
– Daniel Alencar Souza
can put the script in the event
onchange
of the div– Ricardo Pontual
It worked out, thank you very much
– Daniel Alencar Souza