Skip to content

Adding current date to footer/header #553

Answered by yhatt
yosriayed asked this question in Q&A
Discussion options

You must be logged in to vote

This is a simple example with using JavaScript, based on the answe of StackOverflow. JavaScript replaces <span class="date"> within footers in every page.

---
marp: false
footer: '<span class="date"></span>'
---

Page 1

---

Page 2

---

Page 3

<script>
  window.addEventListener('DOMContentLoaded', function () {
    const now = new Date();
    for (const elm of document.querySelectorAll('footer .date')) {
      elm.textContent = now.toLocaleDateString();
    }
  })
</script>

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@yosriayed
Comment options

@yhatt
Comment options

Answer selected by yosriayed
@yosriayed
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants