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

245
Vistas
Why is my document.querySelector() returning a [object HTMLDivElement] instead of the value?

I have the value 60% stored inside a <div class="value-container"> 60% </div>, however when use this query function document.querySelector(.value-container) to get the value, I get this response instead: [object HTMLDivElement]

Find below my HTML code:

<body>

    <div class="container">
        <div class="circular-progress">
            <div class="value-container"> 60% </div>
        </div>
    </div>

    <script>
        $(document).ready(function(){
            let testing = document.querySelector('.value-container');
            console.log("Testing: " +testing);
        });            
    </script>

</body>

This code above yields:

Testing: [object HTMLDivElement]

The desired yield is:

Testing: 60%

How do I capture the value stored inside my <div class="value-container"> 60% </div>?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

As mentioned above, query selector returns an element, but to get its inner value document.querySelector('.value-container').innerHTML should be added

about 4 years ago · Juan Pablo Isaza Denunciar

0

The other commenters are correct - you need do something with the object you get back from your querySelector.

But if you only care about the raw text (which it looks like in this case as you just want the 60% value), then document.querySelector('.value-container').textContent is slightly more efficient than innerHTML

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