Last active
September 25, 2021 09:49
-
-
Save Ankhena/dc68e4b63011f76d10bb68a3667fd9b6 to your computer and use it in GitHub Desktop.
Colors the selected elements in random colors. Launch: colorBlocks ('. random');
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
const colorBlocks = (block) => { | |
const items = document.querySelectorAll(block); | |
items.forEach(item => { | |
let color = (Math.random().toString(16) + '000000').substring(2, 8).toUpperCase(); | |
item.style.setProperty('--bg-color', '#' + color); | |
}) | |
} | |
colorBlocks('.random'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment