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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:37:44+00:00 2026-06-08T00:37:44+00:00

I am working through head first jquery and I am on a chapter dealing

  • 0

I am working through head first jquery and I am on a chapter dealing with the jquery ui. Specifically, the example is walking through a jquery slider that displays the value of that slider above the slider. Screenshot: https://i.stack.imgur.com/BMksn.png However, I am having great difficulty understanding the code:

THE HTML:

<h3>Distance from Creature (in ft.):</h3>
                <input type="text" id="distance" class="just_display" name="creature_distance" readonly="readonly"/>
                <div id="slide_dist"></div> 

<h3>Creature Weight (in lbs.):</h3>
                <input  type="text" id="weight" class="just_display" name="creature_weight"   readonly="readonly"/>
                <div id="slide_weight"></div>

<h3>Creature Height (in ft.):</h3>
                <input  type="text" id="height" class="just_display" name="creature_height" readonly="readonly"/>
                <div id="slide_height"></div>

THE JQUERY:

//3a. slide_dist
        $( "#slide_dist" ).slider({
            value:0,
            min: 0,
            max: 500,
            step: 10,
            slide: function( event, ui ) {
                $( "#distance" ).val( ui.value);
            }
        });
    $( "#distance" ).val( $( "#slide_dist" ).slider( "value" ));



        //3b. slide_weight

        $( "#slide_weight" ).slider({
            value:0,
            min: 0,
            max: 5000,
            step: 5,
            slide: function( event, ui ) {
                $( "#weight" ).val( ui.value);
            }
        });

        $( "#weight" ).val( $( "#slide_weight" ).slider( "value" ));

        //3c.  slide_height
        $( "#slide_height" ).slider({
            value:0,
            min: 0,
            max: 20,
            step: 1,
            slide: function( event, ui ) {
                $( "#height" ).val( ui.value);
            }
        });

        $( "#height" ).val( $( "#slide_height" ).slider( "value" ));

I am seriously confused by the slide parameter in the slider method:

slide: function( event, ui ) {
        $( "#height" ).val( ui.value);
   }

From what I can tell, this is changing the value above the slider to match whatever the slider’s value is. However, if that is the case, then what does the line following the slider method do:

$( "#height" ).val( $( "#slide_height" ).slider( "value" ));

Arent these lines doing the same thing? Any and all input would be 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-06-08T00:37:45+00:00Added an answer on June 8, 2026 at 12:37 am

    This line:

    slide: function( event, ui ) {
        $( "#height" ).val( ui.value);
    }
    

    Is defining an event handler for the “slide” event as defined by jQueryUI. The event handler updates #height with the updated value of the slider on every mouse move during the slide.

    This line (in the context you’ve given):

    $( "#height" ).val( $( "#slide_height" ).slider( "value" ));
    

    Is simply setting the value of #height to 0 initially (the initial value of the slider is 0, you can see the value option in each slider initialized to 0 with value:0).

    The difference between the two is that the first runs every time the mouse moves on the slider and the second is executed once immediately after the slider is initialized, providing an initial value for the #height element (0 in this case).

    Another way of looking at it is that if the second snippet wasn’t there, the #height element wouldn’t show 0 initially (try removing that line to see what I mean).

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

Sidebar

Related Questions

I am working through Head First Rails and I came across some code that
I'm working my way through 'head first design patterns' and want to use this
I am working my way through Head First Rails, and I keep seeing =>
I'm working my way through Head First C#, and I'm a bit confused on
I am working my way through a book called Head First C#. It doesnt
Still working through JQuery to get data and repopulate portions of a page. Right
I'm working through a small file upload script (learning experience) and I noticed that
In working through the issues with another question, I've found text files with embedded
I am working through the EditableGrid demos modifying the code to understand it and
I'm working through some android tutorials right now in preparation for a two week

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.