Last active
December 18, 2025 13:49
-
-
Save marrisonlab/1ef655c170a12c6e04595167286a49f5 to your computer and use it in GitHub Desktop.
random color
This file contains hidden or 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
| <script> | |
| // 1. Seleziona tutti gli elementi con la classe 'bg-change' | |
| const elements = document.querySelectorAll(".bg-change"); | |
| // 2. Itera su ogni elemento trovato | |
| elements.forEach(element => { | |
| // 3. GENERA UN NUOVO COLORE CASUALE AD OGNI ITERAZIONE del ciclo | |
| const randomColor = "#" + Math.floor(Math.random() * 16777215).toString(16).padStart(6, '0'); | |
| // 4. Applica il nuovo colore all'elemento corrente | |
| element.style.backgroundColor = randomColor; | |
| }); | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment