html range 联动,HTML Range Slider and jQuery?

印辉
2023-12-01

Yes, you can do it with html5 elements and jQuery, like this:

HTML:

JS:

var slider = $('#chance_slider'),

textbox = $('#chance');

slider.change(function() {

var newValue = parseInt($(this).val());

textbox.val(newValue);

});

textbox.change(function() {

var newValue = parseInt($(this).val());

slider.val(newValue);

});

EDIT

To allow decimals:

var slider = $('#chance_slider'),

textbox = $('#chance');

slider.change(function() {

var newValue = $(this).val();

textbox.val(newValue);

});

textbox.change(function() {

var newValue = $(this).val();

slider.val(newValue);

});

 类似资料: