Nomuarch
-
Posts
2 -
Joined
-
Last visited
Content Type
Forums
Gallery
Blogs
Events
Store
Downloads
Profiles
Posts posted by Nomuarch
-
-
Site URL: https://commercial.jrbullock.com/
Greetings,
I am trying to have a different header colour each time the page loads. I have patched this code together from a few sources.
I am using an array for the colours. I think I am close to a solution but I have run out of knowledge.
<script type="text/javascript"> //colour change on refresh var colorArray = ["#003D44", "#096570", "#164487", "#FFFF99", "#2252A0", "#72220D"]; const headerr = document.querySelector('.header-announcment-bar-wrapper') function getRandomColor() { return colorArray[Math.random() * colorArray.length | 0]; } console.log(getRandomColor()); window.addEventListener('load', ()=> { headerr.style.backgroundColor * getRandomColour }); </script>
Any help would be greatly appreciated.
Change Header colour on page refresh
in Customize with code
Posted
I have used this answer provided from a different site:
Thanks to all who have answered here.