我正在使用滑动缩放获取值并返回输入框。
我正在检查是否有条件, 函数返回值第一次输出右Ui.value = 10,但2时间显示滑动刻度值
如何查看条件?
$("#sliders #slider-range-min").slider({
range: "min",
value: 0,
min: 0,
max: 5500,
slide: function(event, ui) {
if (ui.value >= '1' && ui.value <= '1000' ) {
ui.value = 10;
}
else if (ui.value >= '10001' && ui.value <= '24999' ) {
ui.value = 25;
//console.log(ui.value);
}
else if (ui.value >= '25000' && ui.value <= '54999' ) {
ui.value = 50;
}
else if (ui.value >= '55000') {
ui.value = 100;
}
console.log(ui.value);
return $("#sliders #amount3").val("$" + ui.value);
}
});
答案 0 :(得分:1)
这里我得到了解决方案......
使用以下代码
$("#sliders #slider-range-min").slider({
range: "min",
value: 0,
min: 0,
max: 5500,
slide: function(event, ui) {
if (ui.value >= '1' && ui.value <= '1000' ) {
ui.value = 10;
}
//else if (ui.value >= '10001' && ui.value <= '24999' ) {
else if (ui.value >= '1001' && ui.value <= '2499' ) { //
ui.value = 25;
//console.log(ui.value);
}
//else if (ui.value >= '25000' && ui.value <= '54999' ) {
else if (ui.value >= '2500' && ui.value <= '5499' ) {
ui.value = 50;
}
//else if (ui.value >= '55000') {
else if (ui.value >= '5500') {
ui.value = 100;
}
console.log(ui.value);
return $("#sliders #amount3").val("$" + ui.value);
}
});
尝试小提琴FIDDLE
希望它有帮助.........