jQuery UI Slider: move the value along (with) the handle

前端 未结 6 1435
谎友^
谎友^ 2020-12-25 08:31

I used the jQuery UI slider component in my page to set a range of prices. I can also use their ui.values[] to set and show the new values in other divs.

6条回答
  •  长情又很酷
    2020-12-25 08:51

    I would just put the labels inside the handles, instead of repositioning them all the time, like in this answer: https://stackoverflow.com/a/7431057/1250436

    $("#slider").slider({
        range: true,
        min: 100,
        max: 500,
        step: 10,
        values: [100, 500],
        animate: 'slow',
        create: function() {
            $('#min').appendTo($('#slider a').get(0));
            $('#max').appendTo($('#slider a').get(1));
        },
        slide: function(event, ui) { $(ui.handle).find('span').html('$' + ui.value); }
    });
    

    Update

    This doesn't work in Chromium for Linux. A strange gfx error occurs.

    See the working demo: http://jsfiddle.net/ohcibi/RvSgj/2/

提交回复
热议问题