Height property of jQuery and Javascript, what’s the difference?

Asked

Viewed 161 times

10

What’s the difference between $(window).height() from jQuery to the screen.height javascript ? Using them I perceive different results...

And what’s similar to screen.height in jQuery ?

2 answers

14


The two functions deal with different aspects:

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

The object screen Javascript forwards the resolution of the user screen, so that the size of the browser window does not interfere with its values. The object $(window) used by jQuery precisely deals with the browser window, and $(window).height() is equivalent to the function window.innerHeight in pure Javascript.

The object screen is not dealt with by jQuery. But as @Jader said in his reply, jQuery is nothing more than Javascript, that is, you can use screen.height with your jQuery code smoothly.

6

In jquery the $(window).height() is the size of the view window (viewport), already screen.height is the total screen size of the user.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.