1
I have a question when it comes to capturing the element with Dom;
Example
let paragrafo = document.getElementById('paragrafo').innerHTML;
All right so far so good, with this I can see the contents of my paragraph, but why I can’t change the value of my captured element, as an example below
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<p id="paragrafo"></p>
<button onclick="colocarConteudo()">inserir texto</button>
<script type="text/javascript">
let conteudo = document.getElementById('paragrafo').innerHTML;
function colocarConteudo(){
conteudo = `Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non
proident, sunt in culpa qui officia deserunt mollit anim id est laborum.`;
}
</script>
</body>
</html>
Let is not used for local variable? , try with var
– Raph Apresentacao
Guy tried but didn’t give either
– diogo.alves