jquery - My jquery code for showdays was working with accurate date now but now it is 1 day less
问题描述
below is my code. It was working fine but now the days til task is off by 1? Also if anyone can help me put like a count on my div where it shows the number of inputed tasks each time the add button gets click and sort the tasks by the dates automatically
jQuery(
function() {
$("#tbDate").datepicker({
dateFormat: "MM dd, yy",
onSelect: function() {
showDays();
}
});
$("#addBtn").click(
function() {
var tskTxt = $("#addTb").val();
$("#ulData").append("<li style = 'font-family: arial;'><strong>" + tskTxt + "</strong></li>");
var dateTxt = $("#tbDate").val();
$("#ulData").append("<li style = 'font-family: arial;'><strong>" + dateTxt + "</strong></li>");
$("#ulData").append("<li style='font-size: 14px;'>" + "# of Days until deadline: " + diff + " days" + "</li>");
$(".clear").val("");
});
function showDays() {
var now = new Date();
var end = $("#tbDate").datepicker("getDate");
diff = Math.round((end.getTime() - now.getTime()) / (86400000));
}
});
解决方案
推荐阅读
- performance - 与 CPU 相比,内存复制在 GPU 上花费的时间更多
- java - 通过键从HashMap中获取值
- google-apps-script - 在电子表格中切换工作表时如何触发功能?
- hibernate - netbeans 11.0 版是否有休眠插件?
- r - 使用 dplyr 创建一个通用的描述表
- c++ - C++ => 没有构造函数可以采用源类型,或者构造函数重载决议不明确
- php - 正则表达式匹配不在特定 div 中的标题标签
- javascript - 如何让 magnific popup 与数组一起使用
- python - Keras 中 LSTM 模型训练一个时期中步数的重要性
- php - 使用 date_sunrise() 和 date_sunset() php 计算白天和晚上的时间量