sarahrab Posted July 15 Share Posted July 15 I'm trying to create a block in which a single word changes out on an automatic timer. In the header section body copy, the last word ("innovation") will change to 3 different words automatically. I'm using an HTML block for this block of text due to other formatting needs. Is this possible? https://allumiaventures.squarespace.com/home pw: providence Link to comment
Solution Lesum Posted July 15 Solution Share Posted July 15 @sarahrab Hi! I just created this solution based on what you described: First add the following body text inside a code block: <p id="auto-changing-text">With a proven track record of financial and strategic returns across two funds and 28 companies, Allumia Ventures is your partner in <span id="auto-change-word">innovation</span>.</p> Then add the following code in Website > Pages > Website Tools > Code Injection > Header <script> const words = ["innovation", "second text", "third text"]; let index = 0; function changeWord() { index = (index + 1) % words.length; document.getElementById("auto-change-word").innerText = words[index]; } setInterval(changeWord, 2000); </script> Inside this line of code add the words, I added the first word "innovation" const words = ["innovation", "second text", "third text"]; Let me know how it goes. Thank you! If my comments were useful, please like or mark my solution as answer so others can scroll to it quickly. Sam Web Developer & Digital Designer ☕ Did you find my contribution helpful? Buy me a coffee? Link to comment
sarahrab Posted July 16 Author Share Posted July 16 That works beautifully! Thank you! Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment