Shortest way to print current year in a website

前端 未结 12 521
鱼传尺愫
鱼传尺愫 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:41

    The Accepted Answer Does Not Always Work

    A recent update has caused all of my WordPress footer copyright dates to get pushed down to then end of the page instead of writing it inline like it used to. I'm sure there are other cases where this may happen as well, but this is just where I've noticed it.

    If this happens, you can fix it by creating an empty span tag and injecting your date into it like this:

     
    

    or if you have jquery enabled on your site, you can go a bit more simple like this:

     
    

    This is similar to Adam Milecki's answer but much shorter

提交回复
热议问题