Created
April 6, 2022 10:40
-
-
Save olygood/aa3d63efcb5377ba26b37141b9347bdf to your computer and use it in GitHub Desktop.
js 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
const setBg = () => { | |
const square = document.querySelector('.items'); | |
const randomColor = Math.floor(Math.random()*16777215).toString(16); | |
console.log(square); | |
square.style.background = "#" + randomColor; | |
// console.log(square); | |
} | |
setInterval(setBg,1000); | |
const tabColor = ['#e9ecef','#dee2e6','#ced4da','#adb5bd','#6c757d','#343a40','#D64933']; | |
const setbg2 = ()=>{ | |
const square2 = document.querySelector('.items2'); | |
//chiffre random---------------- | |
let chiffreRandom = tabColor.length; | |
chiffreRandom = Math.floor(Math.random()*chiffreRandom) | |
// console.log(chiffreRandom); | |
const doneTab = tabColor[chiffreRandom]; | |
console.log(doneTab); | |
square2.style.background = doneTab; | |
console.log(square2); | |
} | |
setInterval(setbg2,1000); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment