我想要带有小时:时间:第二格式的范围滑块

时间:2019-04-03 06:49:25

标签: jquery jquery-ui

$(function() {
    $("#slider-range").slider({
        range: true,
        min: 0,
        max: 140,
        slide: function(e, ui) {

            var hours = Math.floor(ui.value / 60);
            var minutes = ui.value - (hours * 60);
            var second = ui.value - (minutes * 60);

            if (hours.toString().length === 1) hours = '0' + hours;
            if (minutes.toString().length === 1) minutes = '0' + minutes;
            if (second.toString().length === 1) second = '0' + second;

            $('#amount').val(hours + ':' + minutes + ':' + second);
        }
    });
    $("#amount").val($("#slider-range").slider("values", 0) +
        " " + $("#slider-range").slider("values", 1));
});

0 个答案:

没有答案