I'm creating a site that has has many events and days/holidays, they have a function that happens when countdown to that date completes, all similar to this ..

$(document).ready(function() {
$("#TheEvents").countdown({
date: "july 04, 2014 12:00",
"onComplete" : function(event) { 
$(".ThisEvent").slideUp("slow");  
}           
});
});

Since they all have a set date every year my question is - is there a way to put the current year were '2014' is like {TheCurrentYear} ?

I really dont want to have to go and change to 2015 etc. to restart countdown after every event completes :-)

Thanks for your help.

有帮助吗?

解决方案

Just calculate the year dynamically by creating a new Date object, and then calling getFullYear():

$("#TheEvents").countdown({
    date: "july 04, " + new Date().getFullYear() + " 12:00",
    onComplete : function(event) { 
        $(".ThisEvent").slideUp("slow");  
    }           
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top