Mohamed Said Mohamed Said - 1 month ago 6
jQuery Question

How to check the document scrollTop?

if( $('html,body').scrollTop() != 150 ){
$('html,body').animate({scrollTop: 150},'slow');

I'm trying to check if the height of the scroll is not 150, and if that's true I'd like to move the scroll to 150, How can I do this ?

Answer Source

Hiya try this working demo

This will help, Please let me know if I am missing anything,

scrollTop: $(window).scrollTop() + 150 should do the trick.

Jquery code

  if ($('html,body').scrollTop() != 150) {
        scrollTop: $(window).scrollTop() + 150
    }, 'slow');