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

  • Home
  • SEARCH
  • 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 3495490
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T12:07:59+00:00 2026-05-18T12:07:59+00:00

I am using offset() to get the current position of an image just after

  • 0

I am using offset() to get the current position of an image just after a UL. I am positing the image absolutely so that it hangs off the first li as a pointer. When any li is clicked i want the image to slide to that particular li.

The first time i click on a li it slides to the centre of the page. But then when i make subsequent clicks it moves the proper distance, only in the centre of the page because its already been set incorrectly.

I hope this makes sense.

Here is my HTML

<ul id="llist">
    <li class="t current"><a href="#"><span>solutions</span></a><img src="images/bg-tab-leader-arrow.png" width="24" height="53" title="pointer" class="pointer" /></li>
    <li class="m"><a href="#"><span>credit mangement solutions</span></a></li>
    <li class="b"><a href="#"><span>third party additions</span></a></li>
</ul>

and my JS to date (which also nicely fades out tabs)

$('#llist li').click(function() {
    var thisTop = $(this).offset().top;
    $('.pointer').animate( {'top': thisTop} );
    return false;
});

CSS:

#subheader { position:relative; }
#subheader #llist { float:left; width:286px; margin:0 0 18px 0; padding:0; list-style:none; }
#subheader #llist li { color:#005474; line-height:68px; height:70px; background:url(../images/bg-tab-leader.png) no-repeat; position:relative; }
#subheader .pointer { z-index:1000; position:absolute; top:9px; right:-22px; }

Any ideas on why this positions itself in the centre of the page when i first click instead of just sliding it to the relative LI would be greatly appreciated.

  • 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-05-18T12:08:00+00:00Added an answer on May 18, 2026 at 12:08 pm

    I’m a little bit confused by this line:

    var thisTop = $('#llist').offset().top;
    

    …since it gets the top position of the llist, not the <li> that was clicked.

    If I change it to:

    var thisTop = $(this).offset().top;
    

    …it seems to work fine.

    Example: http://jsfiddle.net/patrick_dw/hxAzW/1/


    EDIT:

    The issue may be that you need to use .position() instead of .offset(), so that it uses the relative position of the <li> within the container.

    EDIT:

    Also looks like you need to give relative positioning to the container llist.

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

Sidebar

Related Questions

How to find the offset client position of an element using Javascript? (I assume
greetings all i am using the following method to get the current time in
I am using offset to get a range of the last 7 entries in
how do you get the matching fuzzy term and its offset when using Lucene
I'm trying to perform hidden line removal using polygon offset fill. The code works
Does anyone know if the LIMIT and OFFSET clause work when using the UPDATE
I'm using System.IO.Stream.Read(byte[] buffer, int offset, int count) . Is there an alternative to
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
The requirement is to simply to get the current wall time ( including the

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.