Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

168
Visualizações
why queryselector returns the name of the selector and not the content

I am currently following an online class and I can't understand why I don't have the same thing as the teach in my console.

I have an h1 in my HTML, followed by this :

<script type="text/javascript">
    console.log(document.querySelector('h1'));
</script>

I am supposed to get the content of the h1 in my console but it returns me the selector title. I have not found something that could help me in @.. (and just to be sure I tried it on several browsers).

EDIT : I am supposed to get this:

An image showing the tag I'm Mr. JavaScript in the browser console

And i get this:

An image showing an expandable  element in the browser console

FINAL EDIT : Thank you everyone, I believe this is only a matter of browser (didn't work on Chrome and Firefox but ok on Edge).

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

you just need to add the .innerHTML at the end.

<script type="text/javascript">
    console.log(document.querySelector('h1').innerHTML);
</script>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda