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

Is there a javascript (jquery) slider that limits the values independently of the display values? - Stack Overflow

programmeradmin1浏览0评论

I wish to have a slider that is from 0-100 but that is only selectable from 0-75 (for example)

An example look would be something like this, with the slider restricted from entering the coloured region

Clearly I would like to be able to set the max, min, limit and value of the slider...

As far as I can see the jquery UI Slider does not allow this out of the box. I expect it is possible to extend the basic behaviour but I would need a very clear hand holding to make that work!

I wish to have a slider that is from 0-100 but that is only selectable from 0-75 (for example)

An example look would be something like this, with the slider restricted from entering the coloured region

Clearly I would like to be able to set the max, min, limit and value of the slider...

As far as I can see the jquery UI Slider does not allow this out of the box. I expect it is possible to extend the basic behaviour but I would need a very clear hand holding to make that work!

Share Improve this question asked Aug 22, 2011 at 14:43 LooferLoofer 6,9939 gold badges65 silver badges106 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 9

You can use the slide event of slider plugin which is triggered on every mouse move during slide. Use ui.value to obtain the value of the current handle and check for the max limit and return false. Returning false from this callback prevents the slide.

$(".selector").slider({
   slide: function(event, ui) { 
       if(ui.value > 75){//Note the value of ui.value is between 0 to 99
          return false;
       }
   }
});

For the background color of the slider you can easily achieve it through css.

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论