Skip to content

Instantly share code, notes, and snippets.

@mattgaidica
Last active May 26, 2023 20:36
Show Gist options
  • Save mattgaidica/6b21d4af373036724a1d161977f902ee to your computer and use it in GitHub Desktop.
Save mattgaidica/6b21d4af373036724a1d161977f902ee to your computer and use it in GitHub Desktop.
Rotating text snippet
<div class="is-content-justification-center" style="text-align:center">
<p>Did you know? <span id="rotatingText"><a target="_blank" href="https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0094215">Your brain slow down at 24, but peaks for some cognitive skills at other ages</a>.</span></p>
</div>
<script>
var textArray = [
'<a target="_blank" href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC2754571/">The human brain is the fattest organ in the body, consisting of at least 60% fat</a>.',
'<a target="_blank" href="https://pubmed.ncbi.nlm.nih.gov/20329590/">Your brain can generate about 20 watts of electrical power</a>.',
'<a target="_blank" href="https://www.frontiersin.org/articles/10.3389/fnmol.2018.00216/full">Your brain uses about 20% of your bodys total energy and oxygen intake</a>.',
'<a target="_blank" href="https://www.brainline.org/author/brian-greenwald/qa/can-brain-itself-feel-pain">Your brain is incapable of feeling pain</a>.',
'<a target="_blank" href="https://www.discovermagazine.com/health/numbers-the-nervous-system-from-268-mph-signals-to-trillions-of-synapses">Information in your brain travels at speeds up to 268 miles/hour</a>.',
'<a target="_blank" href="https://www.nia.nih.gov/news/new-hippocampal-neurons-continue-form-older-adults-including-those-mci-alzheimers">Humans continuously grow new brain cells throughout life</a>.',
'<a target="_blank" href="https://www.health.harvard.edu/mind-and-mood/exercise-is-an-all-natural-treatment-to-fight-depression">Exercise can reduce clinical depression</a>.',
'<a target="_blank" href="https://health.clevelandclinic.org/why-do-we-dream">Dreams might serve many roles from memory consolidation to rehearsing real-life actions</a>.'
];
var currentIndex = 0; // Current index of the displayed text
function rotateText() {
document.getElementById("rotatingText").innerHTML = textArray[currentIndex];
currentIndex = (currentIndex + 1) % textArray.length; // Update the index
}
setInterval(rotateText, 3000); // Rotate
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment