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

135
Vistas
The .style of my class is null in javascript

I have a simple web page where on the top there´s a div with this:

<div class="divmain-login">
    <div class="divmain-sup-login">
        <div class="textos">
            <h1>Manejo de archivos</h1>
            <h2>Gaspar Giménez 2021</h2><h3>v 1.2</h3>
        </div>
    </div>
</div>

I want to have the attribute height of this block (with the class .divmain-sup-login) with this JS code:

function setDivSupHeight(){
const DivSup = document.querySelector(".divmain-sup-login");
console.log(DivSup.getAttribute("style"));

    const divh = DivSup.style.height;
    console.log(divh);
}

    setDivSupHeight();

The console returns this:

null (line 3)

nothing (line 7)

The atrribute style returns null, and this is the CSS:

.divmain-sup-login{
position: sticky;
background-color: #F56D7B;
text-align: center;
width: 100vw;


height: 90px;
    display: flex;
    flex-flow: column wrap;
    justify-content: center;
    align-content: center;
}

I dont know how can i get the height of this block.

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

0

Element.getAttribute('style') and Element.style refer to the style="..." attribute of the element - not to anything coming from style rules or final computed style, and in your case that attribute was not used indeed so it's value is null.

What you actually probably want here is Element.getComputedValue().getProperty(), see https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle

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