基本上我想在值增加和减少时运行两个函数。如何检查用户幻灯片向右(当值增加时)和向左(当值减小时)这里是小提琴:
http://jsfiddle.net/BxY99/436/
谢谢!
设置一个临时变量并将其与滑块的当前值进行比较。
var last = 0;
$(".slider").slider({
range: "min",
value: 1,
min: 1,
max: 600,
slide: function(event, ui) {
if (ui.value > last) $("#amount").val("this is increasing");
if (ui.value < last) $("#amount").val("this is decreasing");
last = ui.value;
}
});
试试这个:http: //jsfiddle.net/BxY99/439/
var lastValue = 0;
$(".slider").slider({
range: "min",
value: 1,
min: 1,
max: 600,
slide: function( event, ui ) {
if(ui.value > lastValue) {
$( "#amount" ).val( "this is increasing" );
} else {
$( "#amount" ).val( "this is decreasing" );
}
lastValue = ui.value;
}
});