我想在刷新页面并单击添加任务按钮时突出显示过期的任务,例如以下代码:
$(document).ready(function(){
$('.add-task').on('click',function(){
$('.task-date').each(function(){
var a = new Date().dateFormat('dd/mm/yy').getTime();
var b = formatDate(b,'dd/mm/yy').getTime();
var task = new Date($('.task-date')).getTime();
if(task < b) {
return $('todo-task').addClass('overdue');
}
});
});
});
答案 0 :(得分:0)
var generateElement = function(params){
var parent = $(codes[params.code]),
wrapper;
if (!parent) {
return;
}
var curDate=new Date();
var overDueClass="";
if(params.date<curDate){ // Check the current date is less than to-do date here
overDueClass=" overdue";
}
wrapper = $("<div />", {
"class" : defaults.todoTask+overDueClass,
"id" : defaults.taskId + params.id,
"data" : params.id
}).appendTo(parent);
.....................
...............
}
为解决您的任务,无需创建新功能。您可以只在generateElement
文件的todo.js
函数中应用逻辑。
答案 1 :(得分:0)
var d = new Date();
var date = d.getDate() + "/" + d.getMonth()+1 + "/" + d.getFullYear();
var overDueClass= "";
// Add Task
var generateElement = function(params){
var parent = $(codes[params.code]),
wrapper;
if (!parent) {
return;
}
// Check the current date is less than to-do date.
if(params.date < date) {
overDueClass= "overdue";
} else {
overDueClass="";
};
wrapper = $("<div />", {
"class" : defaults.todoTask+" "+overDueClass,
"id" : defaults.taskId + params.id,
"data" : params.id
}).appendTo(parent);