Height property of jQuery and JavaScript, what difference?

10

What is the difference between $(window).height() of jQuery and screen.height of JavaScript? Using them I notice different results ...

And what is similar to screen.height in jQuery?

    
asked by anonymous 07.09.2014 / 02:06

2 answers

14

The two functions deal with different aspects:

  • screen.height = height based on monitor resolution
  • $(window).height() = browser height

The screen object of JavaScript refers to the screen resolution of the user, so that the size of the browser window does not interfere with its values. Since the $(window) object used by jQuery is just the browser window, $(window).height() is equivalent to the window.innerHeight function in pure JavaScript.

The screen object is not handled by jQuery. But as @Jader said in his response, jQuery is nothing more than JavaScript, meaning you can use screen.height with your jQuery code smoothly.

    
07.09.2014 / 02:18
6

In jquery, the $(window).height() is the size of the viewport, since screen.height is the total size of the user's screen.

Keep in mind that jquery is javascript, and you can use screen.height in it with no problem, if the case is to get the screen size ...

    
07.09.2014 / 02:17