Skip to content Skip to sidebar Skip to footer

How To Auto Detect The Scrolltop Position Of A Particular Div?

I was trying to implement the scroll based animation. I mean i want to animate the content of a particular div when it comes in the view. To achieve this i have given the hard code

Solution 1:

you can use the offset method:

$("#myDiv").offset().top

Solution 2:

To find the position of a div compared to the page, you would use .offset().

var divTop = $('div').offset().top;

This will give you a variable for the top of the selected container. You just put that in where you have:

if($(window).scrollTop() > divTop)

Solution 3:

You can find the position of an element using jQuery:

$("YOURSELECTOR").position().top;

Post a Comment for "How To Auto Detect The Scrolltop Position Of A Particular Div?"