views:

395

answers:

3

How can I have a jQuery slider that is readonly? One that would display a value but the user wouldn't be allowed to move it?

Thanks

A: 

You would simply have to do this:

$('#mySlider').slider( 'disable' );
karim79
This is making the slider disappear (not being rendered).
+2  A: 

The documentation says there's a .slider('disable') function - not sure what that actually does to the slider element itself, but that may be an option for you.

Documentation here

inkedmn
This is making the slider disappear (not being rendered).
Then I suppose the easiest way to do it would be to position a transparent element on top of the slider (thus preventing the user from moving it manually) and control its position using the .value attribute.
inkedmn
A: 

I have got the same issue that the slider disappears if I use directly $('#mySlider').slider( 'disable' );. I have loaded the slider fisrt..then disabled it. Though it is not a good way, but it works for me.

$('#mySlider').slider(
            {
                range: "min",
                min: 0,
                max: 100,                
                value: $("span", this).text(), 

                }

            });
$('#mySlider').slider( 'disable');
miti737