1

fiddle

$("#other-content").click(function() {
    var dest = $('input[value="skip0"]').offset().top;
    console.log(dest, typeof(dest));
    $("html, body").animate({ scrollTop: dest });
});

I can't figure out why I can click the red bar and the window will scroll, but if I click the orange one, it doesn't

The difference is that I am referencing a hidden inputs placement for the scrolling of the orange bar

If I scroll and then click the orange bar, the top property of the input changes. Not sure why

I realize the input's top position is 0, but even if it is at 900, it doesn't work correctly

user1637231
  • 151
  • 10

1 Answers1

0

The question of why the hidden input has no offset is answered here jquery: get the offset of hidden element

Q: "how can i get the coordinates of a hidden element? .offset() doesnt support the use for hidden elements.

any hints?

thanks!"

A: "If your element has had .hide() called on it, or if it's got display:none in css, the browser doesn't bother rendering it at all. In this case, the answer is not directly. In recent jQueries, you can't even get its width or height."

Community
  • 1
  • 1
Zack
  • 2,789
  • 33
  • 60
  • That makes sense, but I can log out the top position value locally. The typeof is a number. I can add it to other numbers too, but for some reason when I try to use it as the value for scrollTop, it doesn't work – user1637231 Sep 19 '14 at 20:08
  • it's sibling works, so I will just use that. thanks! – user1637231 Sep 19 '14 at 20:11