jQuery ui滑块-如果在滑动时值增加或减少 [英] jQuery ui slider - if value increases or decreases when sliding

查看:83
本文介绍了jQuery ui滑块-如果在滑动时值增加或减少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

基本上,我想在值增加和减少时运行两个函数.我该如何检查用户幻灯片向右滑动(当值增加时)和向左滑动(当值减小时):

Basically i want run two functions when value increases and decreases. How can I check user slides to the right (when value increases) and to the left (when value decreases) here is fiddle:

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

谢谢!

推荐答案

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

Set a temp var and compare it to the slider's current value.

jsFiddle示例

jsFiddle example

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;
    }
});​

这篇关于jQuery ui滑块-如果在滑动时值增加或减少的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆