这是我的基于输入字段答案的24小时版本。
Javascript的中文翻译为“JavaScript”。
jQuery(function() {
jQuery( #slider-time ).slider({
range: true,
min: 0,
max: 1440,
step: 15,
values: [ 600, 1200 ],
slide: function( event, ui ) {
var hours1 = Math.floor(ui.values[0] / 60);
var minutes1 = ui.values[0] - (hours1 * 60);
if(hours1.length < 10) hours1= 0 + hours;
if(minutes1.length < 10) minutes1 = 0 + minutes;
if(minutes1 == 0) minutes1 = 00 ;
var hours2 = Math.floor(ui.values[1] / 60);
var minutes2 = ui.values[1] - (hours2 * 60);
if(hours2.length < 10) hours2= 0 + hours;
if(minutes2.length < 10) minutes2 = 0 + minutes;
if(minutes2 == 0) minutes2 = 00 ;
jQuery( #amount-time ).val(hours1+ : +minutes1+ - +hours2+ : +minutes2 );
}
});
});
HTML (超文本标记语言)
<label for="amount-time">Time</label>
<input type="text" name="amount-time" id="amount-time" style="border: 0; color: #666666; font-weight: bold;" value="10:00 - 20:00"/>
<div id="slider-time"></div><br>