HTML how do I insert dynamic date in webpage

前端 未结 8 2104
暖寄归人
暖寄归人 2021-01-05 14:40

I have a static webpage, nothing changes dynamically. However the client wants a date insert into text within the page. The date will always be the current daet plus one day

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-05 15:25

    I recommend XDate because it will save a lot of typing. Also, please don't use innerHTML, it's such a bad habit. I just did the same on a web page and the key thing was to use inline javascript beneath the tag you are updating although you can use 'onload' as well.

    In the page I add the tag and put in some default info just because:

    Today is November 1, 2015

    With this below that:

    
    

    NB: I do use innerHTML to quickly obliterate nested tags rather than a recursive "delete all children" because that's in a different library and not pertinent to this example.

    See http://arshaw.com/xdate/

提交回复
热议问题