使用英寸的jquery ui滑块 [英] jquery ui slider using Inches
问题描述
使用带有英寸的Jquery UI滑块。
我知道如何让滑块使用标准数字,例如:0到100,但我不知道如何获得英寸工作。
我假设需要额外的计算 - 也许。
任何关于如何获得的建议这一个工作?
function toFeet(n){
return Math.floor(n / 12)+'+(n%12)+''';
}
$(函数(){
$(#slider)。slider({
min:55,
max:85,
values :[60,80],
范围:true,
slide:function(event,ui){
// ui.values [0]和ui.values [1]是滑块处理值
$(#result .min)。html(toFeet(ui.values [0]));
$(#r esult .max)。html(toFeet(ui.values [1]));
}
});
});
您只需要将滑块的最小值和最大值成英寸。滑动滑块时,可以通过简单转换(在 toFeet
方法中实现)显示英尺和英寸。
示例: http://jsfiddle.net/andrewwhitaker/4extL/ 57 /
I need to use a Jquery UI Slider with Inches.
I know how to get the slider to work with standard numbers eg: 0 to 100 but I'm not sure how to get inches to work.
I assume an extra calculation is needed - maybe.
Any advice on how to get this one working?
Here's something that should get you started:
function toFeet(n) {
return Math.floor(n / 12) + "'" + (n % 12) + '"';
}
$(function () {
$("#slider").slider({
min: 55,
max: 85,
values: [60, 80],
range: true,
slide: function(event, ui) {
// ui.values[0] and ui.values[1] are the slider handle values.
$("#result .min").html(toFeet(ui.values[0]));
$("#result .max").html(toFeet(ui.values[1]));
}
});
});
All you need to do is translate your slider minimum and maximum values into inches. When sliding the slider, you can display feet and inches by doing a simple conversion (implemented here in the toFeet
method).
Example: http://jsfiddle.net/andrewwhitaker/4extL/57/
这篇关于使用英寸的jquery ui滑块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!