我必须使用date作为min和max来设置JQuery滑块的值。 这是我的代码:
$( "#slider" ).slider({
range: true,
min: 0,
max: 1000,
steps:10,
values: [ 0, 1000 ],
change: function( event,ui ) {
var low = ui.values[0];
var high = ui.values[1];
$("#slider").slider("refresh");
console.log("begin:"+low+"high"+high);
}
});
提前致谢,不便之处。
答案 0 :(得分:1)
将您的max
和step
设为时间戳,将$(document).ready(function() {
var minDate = new Date('2016-12-31');
var maxDate = new Date('2017-12-31');
$("#slider").slider({
min: minDate.getTime(),
max: maxDate.getTime(),
step: 60 * 60 * 24 * 1000, // 1 day
slide: function(e, ui) {
var currentDate = new Date(ui.value);
$('#now').text(currentDate.toDateString());
}
});
});
设为秒计算您希望增加日期的数量。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<div id="slider"></div>
<span id="now"></span>
var mainData = GetFromExcel();
function StartSaving()
{
for (i = 0; i < totalCount; i++)
{
DoPost(i);
}
}
function DoPost(i)
{
var mainCode = MainData[i].MainCode;
var noOfAllot = MainData[i].NoOfAllotment;
var CompanyCode = MainData[i].CompanyCode;
console.log(mainCode +' Company Code:'+ CompanyCode+':' + noOfAllot);
$.ajax({
url: "Allotment.asmx/DoAllotment",
data: "{MainCode:'" + mainCode + "', sNoOfAllotment:'" + noOfAllot + "',CompanyCode:'" + CompanyCode + "'}", // the data in JSON format. Note it is *not* a JSON object, is is a literal string in JSON format
dataType: 'text',
contentType: "application/json; charset=utf-8",
type: "Post",
async: false ,
success: function (res) {
console.log(res);
},
error: function (res) {
}
});
}
答案 1 :(得分:0)
你并没有特别描述你所追求的是什么,但我之前做过一些日期,有点像这样......
var mindate = new Date('2010-01-01').getTime() / 1000;
var maxdate = new Date('2020-01-01').getTime() / 1000;
$( "#slider" ).slider({
range: true,
min: mindate,
max: maxdate,
step: 86400,
values: [ mindate, maxdate ]
});