Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8247045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:42:37+00:00 2026-06-07T22:42:37+00:00

I have a wierd issue with jQuery which I’ve never seen before. I have

  • 0

I have a wierd issue with jQuery which I’ve never seen before.

I have a bit of script to calculate the position().top value of an element which is always on the page. It’s an li inside a ul inside a div.

The works every time I post a fresh request, normally returns 300.
However if I then hit ctrl-r and redo the request, the same code for the same page returns 0 for position().top. Refreshing again sees it work.

This happens consistently, every 2nd page refresh. However each fresh page request (with changed params or just resubmitting the form) seems to work fine. I haven’t witnessed this strange failure cycle go out of sequence.

caveats

Now on to the caveats (and a bit of code):
I’m using the easing and zebra_datepicker plugins, and have written my own vertical slider plugin which contains the code that consistently fails to get the right position of my element.

So I’m not expecting this to be a common occurrence, nor can I post the full source so instead I’m posting a snippet with the odd code for context more than anything else:

// inside each loop for slider parent elements
// $(this) references the slider container, i.e <div>
var slideTo = $(this).find('.slideTo').position().top; //300 or 0

This code is in the plugin itself, which is then called in a $(window).load() event.

The way this behaves makes me think it’s some kind of race condition but I can’t find anything in my code that does things in the wrong sequence or runs more than once, and believe me I’ve filled it to the gunnels with debug.

tl;dr

So my question is this: are there any circumstances where jQuery.position().top will return 0, given that the targeted element exists and has loaded by the time the call is made?

Are there any silly mistakes I could have made to make this happen; could it be due to invalid markup or maybe something to do with the fact that the element is an li?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T22:42:39+00:00Added an answer on June 7, 2026 at 10:42 pm

    Turns out this wasn’t always returning zero as I had thought.

    What was happening is that when I modified the scrollTop of my parent element, then refreshed the page, Firefox remembered the scrollTop value on the refresh – so my calculation came back as zero then because with the remembered scrollTop value, the position of that element was zero.

    So this behaviour was not buggy at all and position() was doing exactly what it should.

    I got around this problem by setting the scrollTop of my elements to zero before running these calculations, which stopped Firefox’s remembered value from breaking things for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a weird issue. Here is the setup: I have a NSOperationQueue which
I'm running a weird issue here. I have code that makes jquery ajax calls
I'm having an odd issue in FF10 using jQuery 1.7.1. I have a gallery
I have a weird issue whereby I'm programming a carousel-type animation in jQuery. I
I have this weird issue that jquery.load sometimes fails on chrome. I'm not gonna
I'm having a weird issue with my jQuery Autocomplete. I have an autocomplete textbox
I have a really wierd issue that I'm hoping someone can shed some light
I've been having this weird issue with jQuery which came with Wordpress 3.2.1. I'm
I have a weird issue with creating an Bitmap in C++. I'm using the
I have a weird issue when connecting to Oracle with Groovy. I have created

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.