jQuery Slider Range Event on Change: Example & Guide
You can use the jQuery UI slider widget to create a slide range event that fires when the slider is changed. Here's an example:
HTML:
<div id='slider'></div>
<div id='output'></div>
JavaScript:
$(function() {
$('#slider').slider({
range: true,
min: 0,
max: 100,
values: [25, 75],
slide: function(event, ui) {
$('#output').html('Range: ' + ui.values[0] + ' - ' + ui.values[1]);
},
change: function(event, ui) {
// Do something when the slider is changed
}
});
});
This code creates a slider with a range of 0 to 100, initial values of 25 and 75, and a slide event that updates the output div with the current range. It also has a change event that can be used to perform some action when the slider is changed. You can replace the comment inside the change event with your own code.
原文地址: https://www.cveoy.top/t/topic/neTZ 著作权归作者所有。请勿转载和采集!