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

356
Vistas
How do I get document height using vh units in jQuery?
$(window).scroll(function() {
   $scrollingDiv.css("display", (($(window).scrollTop() / $(document).height()) > 0.1) ? "block" : "");
});

How can I change the unit $(document).height()) > 0.1) to 100vh? I don't have much jQuery experience.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

VH : Viewport Height is similar to $(window).height(); Source

So you can check the condition if (windowHeight > 0.1) then

$("body").height(windowHeight);

Code:

$(document).ready(function() {
  var windowHeight = $(window).height();

  if (windowHeight > 0.1) {
    alert("height is greater than 0.1");
    $("body").height(windowHeight);
  } else {
    alert("height is less than 0.1");
  }

});

Codepen link: https://codepen.io/anon/pen/GWzVwO

about 4 years ago · Santiago Trujillo Denunciar

0

I believe the correct syntax is $(selector).attr(attribute,value) So for your specific example $(document).attr('height','100vh')

Here is a link that hopefully helps --> https://www.w3schools.com/jquery/html_attr.asp

about 4 years ago · Santiago Trujillo 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