JQuery UI Slider - 'value' not setting sta

2019-08-18 05:27发布

I would expect the following code to start my slider at '30' in it's range of 0-250, but yet it is not.

$(function() {
  $( "#slider" ).slider({
  value: 30,
  min: 0, 
  max: 250,
  step: 1, 
  slide: function(event, ui){
    $("#edit-varprice").val(ui.value + ".00");
  }  
  });
});

Image : http://gallery.twardnw.com/var/albums/Misc/Screen%20shot%202012-04-03%20at%203.06.59%20PM.png?m=1333490924

3条回答
唯我独甜
2楼-- · 2019-08-18 05:59

try removing the value from the options u chose, and adding it later using:

$( "#slider" ).slider( "option", "value", 40 );
查看更多
▲ chillily
3楼-- · 2019-08-18 06:14

Its working fine for me. See jsFiddle Demo.

Perhaps you are missing something else or doing something in other parts of your code, can you post full code?

查看更多
Emotional °昔
4楼-- · 2019-08-18 06:20

Could you lower your max to 50 and see if the slider handle is offset, if so then its working just fine. In the image it looks like its slightly offset. 30/250 is only 12% and may be deceiving.

查看更多
登录 后发表回答