Last active
August 9, 2021 05:18
-
-
Save minghao912/8434d5163742a2dd5632d22a72955ebd to your computer and use it in GitHub Desktop.
For a club website, will switch out heading text on a delay
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
// Change these as you see fit | |
const BLOCKID = "#block-7c7d6afc1405682f08c2"; // block ID of Squarespace block, found via Inspect Element | |
const TEXT = ["text 1", "text 2", "text 3"]; | |
const DELAY = 1000; // in milliseconds | |
let currentIndex = 0; | |
function textChanger() { | |
console.log("fire"); | |
let block = document.querySelector(BLOCKID); // Get the block that the title is in | |
let el = block.querySelectorAll("h1")[0]; // Get the first h1 element within the block | |
el.innerHTML = `${TEXT[currentIndex % TEXT.length]}`; | |
currentIndex++; | |
} | |
setInterval(textChanger, DELAY); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment