Created
January 3, 2024 16:16
-
-
Save mattsims/d5e1b7f03a2a8795c6364a2b223228c4 to your computer and use it in GitHub Desktop.
Set the text content of specific elements to the current year
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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