Mohamed Said Mohamed Said - 6 months ago 47
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');
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download