最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - jQuery UI slider - can't slide to 0 - Stack Overflow

programmeradmin3浏览0评论

jQuery 1.3.2 / jQueryUI 1.7 / Slider

$("#slider").slider({
    range: "min",
    min: 0,
    max: 40,
    value: 0,
    slide: function(event, ui) {
        CalculateOrder(event, ui);
    }
});

it starts off just fine, but after I move the slider I can't get it back to 0, ui.Value is 1 when i slide it all the way to the left.

I've tried setting

min:-1

this sets the ui.Value to -1 when i slide it to -1, but when I'm at 0 the ui.Value is still 1.

Any ideas?

jQuery 1.3.2 / jQueryUI 1.7 / Slider

$("#slider").slider({
    range: "min",
    min: 0,
    max: 40,
    value: 0,
    slide: function(event, ui) {
        CalculateOrder(event, ui);
    }
});

it starts off just fine, but after I move the slider I can't get it back to 0, ui.Value is 1 when i slide it all the way to the left.

I've tried setting

min:-1

this sets the ui.Value to -1 when i slide it to -1, but when I'm at 0 the ui.Value is still 1.

Any ideas?

Share Improve this question edited Jul 24, 2016 at 21:51 devops 9,1796 gold badges50 silver badges77 bronze badges asked Mar 7, 2009 at 2:01 roman mroman m 26.5k32 gold badges104 silver badges136 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 21

What you want is to get the value when the slider has stop, not during the slide. From my experience, the slide event will get you the previous position of the slider. Stop will give you the value of the slider where the user move it to.

$("#slider").slider({
    range: 'min',
    min: 0,
    max: 40,
    value: 1,
    step: 10,
    slide : function(event, ui){
        console.log("previous value:"+ $(this).slider('option', 'value'));
    },
    stop: function(event, ui){
        console.log("Current value:"+ $(this).slider('option', 'value'));
    }
});
发布评论

评论列表(0)

  1. 暂无评论