Host unlimited files.
Leverage the unparalleled capabilities of OpenAI's GPT4 most recent language model to enhance your Webflow development.
Primed for working with JavaScript within the context of Webflow.


Datamaker
How do I display the current year in a text span?

To display the current year in a text span using JavaScript and Webflow, follow these steps:
1. Add a text element to your Webflow project and give it a unique ID (e.g., `current-year`).
2. Add an Embed element to the page where you want to run the script to update the text span.
3. Inside the Embed element, add the following code:
<script> document.addEventListener("DOMContentLoaded", function () { var currentYear = new Date().getFullYear(); document.getElementById("current-year").innerText = currentYear; });</script>
Replace "current-year" with the ID you assigned to the text element in step 1. Now, when the page loads, the current year will automatically populate in the designated text span.
1. Add a text element to your Webflow project and give it a unique ID (e.g., `current-year`).
2. Add an Embed element to the page where you want to run the script to update the text span.
3. Inside the Embed element, add the following code:
<script> document.addEventListener("DOMContentLoaded", function () { var currentYear = new Date().getFullYear(); document.getElementById("current-year").innerText = currentYear; });</script>
Replace "current-year" with the ID you assigned to the text element in step 1. Now, when the page loads, the current year will automatically populate in the designated text span.
Logged in as Jason | Log out