Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

aula 3

var titulo = document.getElementById("titulo") sempre retorna "null" e quando eu coloco o textContent ele aparece "Uncaught TypeError: Cannot read property 'textContent' of null"

4 respostas

você atribui o id titulo no html?

sim, meu html esta assim :

<!DOCTYPE html>
<html>
<head>
    <title>teste</title>
    <script src="teste.js"></script>
</head>
<body>
<h1 id="titulo">Ola mundo teste</h1>
</body>
</html>
solução!

Problema resolvido, o motivo é que tenho que chamar o script no final da pagina

Estava com o mesmo problema.

Obrigado por compartilhar!

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software