jQuery(window).height inaccurate

后端 未结 6 1713
挽巷
挽巷 2021-01-04 07:24

I\'m doing a simple test on $(window).height() and I\'m getting a value of 2602 on a screen resolution of 1366 x 768.

jQuery(document).ready(function($){

           


        
6条回答
  •  粉色の甜心
    2021-01-04 08:23

    It is my experience that $(document).height(); is typically what you want in most scenarios. The difference being if the page is bigger than the window (has scroll bars), you will get the full height of the entire scrollable document while $(window).height() will only get you the height of the currently sized tab.

    So if you want an element to take up the full size of the window + any scrollable area below the fold $(document).height is the way to go.

    There is definitely a use case for both though.

提交回复
热议问题