Scrolltop js document height

The following Jquery code why not work on mobile?

if ($(window).scrollTop() + $(window).height() == $(document).height()) {