Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

354
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!