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 179883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:29:10+00:00 2026-05-11T14:29:10+00:00

I am using offset() with the jquery slider and I am so close to

  • 0

I am using offset() with the jquery slider and I am so close to achieving my goal, but it is off slighty. I have it animating using animate to the top CSS coordinates but if you check out: http://www.ryancoughlin.com/demos/interactive-slider/index.html – you will see what it is doing. My goal is to have it fadeIn() and display the value to the right of the handle. i know I can offset the text from the handle using a simple margin:0 0 0 20px.

The part is aligning #current_value to the right of the handle. Thoughts? var slide_int = null;

$(function(){      $('h4.code').click(function () {         $('div#info').toggle('slow');     });      $('#slider').slider({         animate: true,         step: 1,         min: 1,         orientation: 'vertical',         max: 10,         start: function(event, ui){             $('#current_value').empty();             slide_int = setInterval(update_slider, 10);          },         slide: function(event, ui){             setTimeout(update_slider, 10);           },         stop: function(event, ui){             clearInterval(slide_int);             slide_int = null;         }     });  }); function update_slider(){     var offset = $('.ui-slider-handle').offset();     var value = $('#slider').slider('option', 'value');      $('#current_value').text('Value is '+value).css({top:offset.top });     $('#current_value').fadeIn();  } 

I know I could use margin to offset it to match, but is there a better way?

  • 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. 2026-05-11T14:29:11+00:00Added an answer on May 11, 2026 at 2:29 pm

    There are two problems. The first, like Prestaul said, the slider event fires at the ‘beginning’ of the move, not the end, so the offset is wrong. You could fix this by setting a timeout:

    $(function(){     slide: function(event, ui){         setTimeout(update_slider, 10);     },     ... }); function update_slider() {     var offset = $('.ui-slider-handle').offset();     var value = $('#slider').slider('option', 'value');     $('#current_value').text('Value is '+value).animate({top:offset.top }, 1000 )     $('#current_value').fadeIn(); } 

    The second problem is that the move is instantaneous, while the animation is not, meaning that the label will lag behind the slider. The best I’ve come up with is this:

    var slide_int = null;  $(function(){     ...     start: function(event, ui){         $('#current_value').empty();         // update the slider every 10ms         slide_int = setInterval(update_slider, 10);     },     stop: function(event, ui){         // remove the interval         clearInterval(slide_int);         slide_int = null;     },     ... });  function update_slider() {     var offset = $('.ui-slider-handle').offset();     var value = $('#slider').slider('option', 'value');      $('#current_value').text('Value is '+value).css({top:offset.top });     $('#current_value').fadeIn(); } 

    By using css instead of animate, you keep it always next to the slider, in exchange for smooth transitions. Hope this helps!

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

Sidebar

Ask A Question

Stats

  • Questions 138k
  • Answers 138k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer FallbackValue is only used when the binding path cannot be… May 12, 2026 at 7:28 am
  • Editorial Team
    Editorial Team added an answer Yeh, it's odd. What I've done previously is check if… May 12, 2026 at 7:28 am
  • Editorial Team
    Editorial Team added an answer You can merge multiple .NET assemblies into one using ILMerge.… May 12, 2026 at 7:28 am

Related Questions

Edit: I put this snippet of code in jsbin: http://jsbin.com/eneru I am trying to
I have a group of text based rules that are structured like this: Rule
I have two divs like so <div id=parent style=width:100px:overflow:hidden;> <div id=child> tooooooooooooooooooooo much content
I am using a slightly modified version of the DotZlib which is part of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.