开发者

Get a value of slide dynamically

I have this demo.

The value only updates if I refresh the page, but my idea is to update the value when the pointer is moved.

I use this plugin but I think that is based on the jQuery UI slider.

In my code I have:

<script type="text/javascript">
$(function(){
  $("#Slide开发者_运维百科rSingle").slider({
    from: 400,
    to: 2000,
    step: 2.5,
    round: 1,
    scale: ['400€', '600€', '800€', '1000€', '1200€', '1400€', 
                                            '1600€', '1800€', '2000€'],
    dimension: '&nbsp;€',
    skin: "round",
    slide: function(event, ui){
      $("#amount").val('$' + ui.value);
    }

  });
  $("#amount").val('$' + $("#SliderSingle").slider("value"));

});
</script>

The only issue is just update the value when pointer is moved.


I don't think this is built on the jQueryUI slider. However, you should be able to use the callback option, which accepts a value parameter:

$("#SliderSingle").slider({
    /* Snip */
    callback: function(value) {
        $("#amount").val("$" + value);
    }
    /* Snip */
});

Working example: http://jsfiddle.net/HKhBH/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜