Hi, today am going to code a js snippet for dynamically updating the footer’s copyright year.
document.getElementById('copyrightYear').innerHTML = new Date().getFullYear();
Place the id (copyrightYear) in a span tag at the footer section after © symbol and before company name.
Place the above code in script tags at the bottom before closing body tag.
You will get the current year without any hassle to update it regularly every year.
If you like the post, share with your friends.
Cheers!
Top comments (5)
document.write is deprecated.
Thank you, edited it. But actually as far I learned no one mentioned that document.write() is deprecated but I think it is a bad practice. Am still a novice in JS. Thank you for pointing it out.
Are you a time traveler from the remote past?
Good one Franco ;)
Excellent.. Am hoping to learn Rails after mastering js and node.