0

As an example, I want to get the scroll positon of the second object in this selector-array

alert($("#sites > div").eq(2).scrollTop());

I know it'S dead simple, but I just can't seem to get it right..

2 Answers 2

2

Arrays are zero-based in JavaScript. So the second object is at position 1. Hence you would have to use eq(1) instead of eq(2).

Sign up to request clarification or add additional context in comments.

1 Comment

Whoops, forgot about that. However, it still won't work, it will always have a "0" in it. I found the "solution" though (answered it myself).
0

Apart from the little mistake that Vivin pointed out (wasn't too relevant here), I just misunderstood the function scrollTop. What I was looking for is this:

alert($("#sites > div").eq(1).position().top);

Stupid me, but it was late yesterday when I ran into this issue, so that's my excuse.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.