Malasorte Malasorte - 5 months ago 8
jQuery Question

If document can be scrolled vertically by 200px or more run function

Using Jquery or plain Js I want to run a function on

document ready
, if the page has a vertical scrollbar and the ammount by wich the page can be scrolled is
or larger.

Basically, I want to modify the code below so that it runs on
document ready
, not when the user actually scrolls.

if ($(this).scrollTop() > 200) {
// do stuff


This is how i would do it.

$(document).ready(function() {
  if(($(document).height() - $(window).height()) > 200)
     //Do something.