Compare date with if statement in jQuery to do list
I want to highlight overdue task when refresh page and when click on add task button such as the code below:
$(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');
}
});
});
});
I tried some other ways but still not working so please check JSFiddle here and source site here and help me. Thank you.
javascript jquery date if-statement compare
add a comment |
I want to highlight overdue task when refresh page and when click on add task button such as the code below:
$(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');
}
});
});
});
I tried some other ways but still not working so please check JSFiddle here and source site here and help me. Thank you.
javascript jquery date if-statement compare
I think you should be usingthishere instead ofvar task = new Date($('.task-date')).getTime();
– secret super star
Nov 23 '18 at 5:49
add a comment |
I want to highlight overdue task when refresh page and when click on add task button such as the code below:
$(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');
}
});
});
});
I tried some other ways but still not working so please check JSFiddle here and source site here and help me. Thank you.
javascript jquery date if-statement compare
I want to highlight overdue task when refresh page and when click on add task button such as the code below:
$(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');
}
});
});
});
I tried some other ways but still not working so please check JSFiddle here and source site here and help me. Thank you.
javascript jquery date if-statement compare
javascript jquery date if-statement compare
edited Nov 23 '18 at 5:37
Shiladitya
9,39391830
9,39391830
asked Nov 23 '18 at 5:34
Nguyễn Đình Hải FX00606
112
112
I think you should be usingthishere instead ofvar task = new Date($('.task-date')).getTime();
– secret super star
Nov 23 '18 at 5:49
add a comment |
I think you should be usingthishere instead ofvar task = new Date($('.task-date')).getTime();
– secret super star
Nov 23 '18 at 5:49
I think you should be using
this here instead of var task = new Date($('.task-date')).getTime();– secret super star
Nov 23 '18 at 5:49
I think you should be using
this here instead of var task = new Date($('.task-date')).getTime();– secret super star
Nov 23 '18 at 5:49
add a comment |
2 Answers
2
active
oldest
votes
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);
.....................
...............
}
For solve your task no need to create new functions. You may just apply the logic in generateElement function in your todo.js file.
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
add a comment |
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);
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441115%2fcompare-date-with-if-statement-in-jquery-to-do-list%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
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);
.....................
...............
}
For solve your task no need to create new functions. You may just apply the logic in generateElement function in your todo.js file.
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
add a comment |
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);
.....................
...............
}
For solve your task no need to create new functions. You may just apply the logic in generateElement function in your todo.js file.
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
add a comment |
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);
.....................
...............
}
For solve your task no need to create new functions. You may just apply the logic in generateElement function in your todo.js file.
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);
.....................
...............
}
For solve your task no need to create new functions. You may just apply the logic in generateElement function in your todo.js file.
answered Nov 23 '18 at 6:32
Sumesh TG
2,0721722
2,0721722
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
add a comment |
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Thank you, i tried some other way base on your answer but it still not working.
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 8:41
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Share your source code through github.
– Sumesh TG
Nov 23 '18 at 8:45
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Thanks for your help @Sumesh TG, this is source code on github: github.com/ndh2311/to-do-list.git
– Nguyễn Đình Hải FX00606
Nov 23 '18 at 11:14
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
Hey, thanks you @Sumesh TG, base on your answer i finished it.
– Nguyễn Đình Hải FX00606
Nov 27 '18 at 6:20
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
@NguyễnĐìnhHảiFX00606 ok
– Sumesh TG
Nov 27 '18 at 6:56
add a comment |
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);
add a comment |
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);
add a comment |
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);
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);
answered Nov 27 '18 at 6:18
Nguyễn Đình Hải FX00606
112
112
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53441115%2fcompare-date-with-if-statement-in-jquery-to-do-list%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I think you should be using
thishere instead ofvar task = new Date($('.task-date')).getTime();– secret super star
Nov 23 '18 at 5:49