Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda