1

I can't figure out what I am getting wrong in the following simple example for a jquery UI slider. Can anyone spot a problem?

<!DOCTYPE html>
<html>
<head>
    <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
    <script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

    <style type="text/css">
        #slider01 { margin: 10px; }

    </style>

    <script>
        $(document).ready( function() {

            var valmin = valmax = 0;

            $("#slider01").slider({
                min: 0, 
                max: 9, 
                slide: function (event, ui) {

                    $('#val01').val($(this).slider('value'));

                }
            });                     
        });
    </script>
</head>

<body style="font-size:62.5%;">  

    <div id="slider01"></div>
    <input type="text" id="val01"/>

</body>
</html> 

Can anyone spot a problem?

1
  • i should mention that i am getting the following values: 1 0 1 2 3 4 5 6 7 Commented Feb 24, 2011 at 19:30

1 Answer 1

3

Use the ui var passed to your slide event.

var valmin = valmax = 0;

$("#slider01").slider({
    min: 0,
    max: 9,
    range: true,
    values: [0, 9],
    slide: function(event, ui) {
        $('#val01').val(ui.values[0]+', '+ui.values[1]);
    }
});

http://jsfiddle.net/petersendidit/wxLez/

Sign up to request clarification or add additional context in comments.

1 Comment

awesome. thanks for that. was getting to me! also noticed that you can use ui.value

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.