jQuery Price Slider: Setting Default Range to 0-2000
To set the default starting and ending values for the price slider to 0 and 2000 respectively, you can modify the code as follows:
$(function() {
$( '#slider-range' ).slider({
range: true,
min: 0,
max: 2000, // Set the max value to 2000
values: [ 0, 2000 ], // Set the default values to 0 and 2000
slide: function( event, ui ) {
$( '#amount' ).html( '$' + ui.values[ 0 ] + ' - $' + ui.values[ 1 ] );
$( '#min' ).val(ui.values[ 0 ]);
$( '#max' ).val(ui.values[ 1 ]);
}
});
$( '#amount' ).html( '$' + $( '#slider-range' ).slider( 'values', 0 ) + ' - $' + $( '#slider-range' ).slider( 'values', 1 ) );
});
This will set the initial values of the slider to 0 and 2000, and the input fields will also have these values initially.
原文地址: https://www.cveoy.top/t/topic/qfg0 著作权归作者所有。请勿转载和采集!