Shortest way to print current year in a website

前端 未结 12 524
鱼传尺愫
鱼传尺愫 2020-12-07 06:45

I need to update a few hundred static HTML pages that have the copyright date hard coded in the footer. I want to replace it with some JavaScript that will automatically upd

12条回答
  •  借酒劲吻你
    2020-12-07 07:39

    TJ's answer is excellent but I ran into one scenario where my HTML was already rendered and the document.write script would overwrite all of the page contents with just the date year.

    For this scenario, you can append a text node to the existing element using the following code:

    © Company Name

提交回复
热议问题