1

基本上我想在值增加和减少时运行两个函数。如何检查用户幻灯片向右(当值增加时)和向左(当值减小时)这里是小提琴:

http://jsfiddle.net/BxY99/436/

谢谢!

4

2 回答 2

4

设置一个临时变量并将其与滑块的当前值进行比较。

jsFiddle 示例

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;
    }
});​
于 2012-09-14T21:04:15.497 回答
1

试试这个: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;
    }
});​
于 2012-09-14T21:09:42.340 回答