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

前端 未结 6 1346
谎友^
谎友^ 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:45

    It's possible to create a nice slider by including bootstrap tooltips. Here's an updated version of the slider using bootstrap tooltips. http://jsfiddle.net/ykay/jL044k1c/

    function slide(event, ui) {
        setTimeout(function () {
            $(ui.handle).attr('title', ui.value).tooltip('fixTitle').tooltip('show');
        }, 0);
    }
    function create(event, ui, start, end) {
        var handles = $(event.target).find('span');
        handles.eq(0).tooltip({animation: false, placement: 'top', trigger: 'manual', container: handles.eq(0), title: start}).tooltip('show');
        handles.eq(1).tooltip({animation: false, placement: 'top', trigger: 'manual', container: handles.eq(1), title: end}).tooltip('show');
    }
    $('#slider').slider({
        range: true,
        min: 0,
        max: 100,
        values: [20, 80],
        slide: function (event, ui) {
            slide(event, ui)
        },
        create: function (event, ui) {
            create(event, ui, $(this).slider('values', 0), $(this).slider('values', 1))
        }
    });
    

提交回复
热议问题