Hitu Bansal
Hitu Bansal

Reputation: 3137

Margin Top on Scroll is not working in Jquery

I have following code. on Scroll height is working, but margin-top is not working. Any idea how to resolve this issue

$(document).scroll(function(){
    if ($(this).scrollTop()>300){
        // animate fixed div to small size:
        $('.secHead a.views').animate({marginTop:"-14px"});
        $('.listTrigger').stop().animate({ height: 45 });

    } else {
        //  animate fixed div to original size

        $('.listTrigger').stop().animate({ height: 82 });

    }
});

Thanks

Upvotes: 0

Views: 41

Answers (1)

jeremyb
jeremyb

Reputation: 492

First be sure that your element with margin-top: -14px works fine.

Then, try replacing this:

$('.secHead a.views').animate({marginTop:"-14px"});

By this:

$('.secHead a.views').animate({'margin-top:"-14px"});

Upvotes: 1

Related Questions