Question

I have a JQuery slider that's working pretty well, but for some reason it's not passing the tenths value.

$(document).ready(function(){
        $("#scoreSlider").slider({
            'steps': 40,
            'min': 1.0, 
            'max': 5.0,
            'startValue': 3, 
            'slide': function(e, ui){ 
                document.getElementById('div_score').innerHTML = ui.value;
            }
        });        
});

It appears that there are the right number of clicks on the slider, but the passed value only has the whole number.

Any ideas.

Was it helpful?

Solution

According to the documentation for Slider,

ui.value: Integer - the current handle's value

Why don't you change your code to this:

$(document).ready(function(){
    $("#scoreSlider").slider({
            'steps': 40,
            'min': 10, 
            'max': 50,
            'startValue': 30, 
            'slide': function(e, ui){ 
                    document.getElementById('div_score').innerHTML = ui.value/10.0;
            }
    });        
});

It seems to produce the decimal values that you desire.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top