[英]jquery ui slider value on slider
I'm curious if anyone has a pre-existing solution to putting the value of the slider in the handle of the slider itself beyond the following: 我很好奇是否有人有预先存在的解决方案将滑块的值放在滑块本身的句柄之外:
$( "#slider-vertical" ).slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 60,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
$(this).find('.ui-slider-handle').text(ui.value);
}
Note: This does not set the initial value of the slider, but I'm aware it needs to be done. 注意:这不会设置滑块的初始值,但我知道需要完成。
Try this 尝试这个
$(function(){
$( "#slider-vertical" ).slider({
orientation: "vertical",
range: "min",
min: 0,
max: 100,
value: 60,
slide: function( event, ui ) {
$( "#amount" ).val( ui.value );
$(this).find('.ui-slider-handle').text(ui.value);
},
create: function(event, ui) {
var v=$(this).slider('value');
$(this).find('.ui-slider-handle').text(v);
}
});
});
An update to this if you're using a range slider to set each slider individually 如果您使用范围滑块单独设置每个滑块,则对此进行更新
$("#slider-vertical").slider({
range: true,
min:0,
max:500,
values:[1,300],
slide: function( event, ui ) {
$(ui.handle).text(ui.value);
},
create: function(event, ui) {
var v = $(this).slider('values');
var c = 0;
$(this).find('.ui-slider-handle').each(function(){
$(this).first().text(v[c]);
c++;
});
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.