Skip to content

Instantly share code, notes, and snippets.

@mattsims
Created January 3, 2024 16:16
Show Gist options
  • Save mattsims/d5e1b7f03a2a8795c6364a2b223228c4 to your computer and use it in GitHub Desktop.
Save mattsims/d5e1b7f03a2a8795c6364a2b223228c4 to your computer and use it in GitHub Desktop.
Set the text content of specific elements to the current year
<script>
const currentDate = new Date();
document.querySelectorAll('[data-text-content="current-year"]')
.forEach((element) => {
element.textContent = currentDate.getFullYear();
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment