Arun
Arun

Reputation: 685

How can I get the actual value of jQuery slider change event?

This is my code for a jQuery mobile slider i would like to use the slider for navigating one page to another. please see my code.

<label for="slider-1">Chapter:</label>
<input type="range" name="slider-1" id="slider-1" value="1" min="1" max="2"   />
<script>
$(document).ready(function(){

        $("#slider-1").change(function() {
        var SliderValue = $("#slider-1").val();
        console.log(slider_value)
                if(SliderValue>0){
                    //window.location = document.location+"#page"+SliderValue;
                }
        });



});
</script>

i just loged the variable SliderValue here i can see the value is increasing upto 295.

can any one tell me how can i get the actual value on the event?

Thanks in advance,

Upvotes: 0

Views: 1851

Answers (1)

Mihai Matei
Mihai Matei

Reputation: 24276

Supply a callback function to handle the change event as an init option.

$( "#slider-1" ).slider({
   change: function(event, ui) { 
       alert(ui.value);
   }
});

Bind to the change event by type: slidechange.

$( "#slider-1" ).bind( "slidechange", function(event, ui) {
    alert(ui.value);
});

Source: jQuery UI Slider Demos

Upvotes: 1

Related Questions