How to reset a jQuery UI slider?

后端 未结 5 1836
梦毁少年i
梦毁少年i 2021-02-07 05:50
    
    
    

        
5条回答
  •  时光取名叫无心
    2021-02-07 06:13

    Check out my answer here jsfiddle

    $(function() {
        var options = 
            {
                range: true,
                min: 0,
                max: 500,
                values: [ 75, 300 ],
                slide: function( event, ui ) {
                    $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] );
                }
            };
    
            $( "#slider-range" ).slider(
                options
            );
            $( "#amount" ).val( "$" + $( "#slider-range" ).slider( "values", 0 ) +
                " - $" + $( "#slider-range" ).slider( "values", 1 ) );
    
        $("#button").click(function()
           {
               $("#slider-range").slider("values", 0, options.values[0]);  
               $("#slider-range").slider("values", 1, options.values[1] ); 
               $( "#amount" ).val( "$" + options.values[0] + " - $" + options.values[1] );           
           });
        });
    

提交回复
热议问题