A beginner-friendly JavaScript mini project that dynamically changes the background and text color of elements using random RGB values.
- Generates random colors using JavaScript
- Applies colors to multiple elements
- Uses DOM manipulation
- Simple and clean logic
- HTML
- CSS
- JavaScript
- Selects all child elements inside a container
- Generates random RGB values
- Applies them as background and text color
- Understanding of DOM selection
- Working with arrays and loops
- Random number generation
- Dynamic styling using JavaScript
- Download or clone the repository
- Open
index.htmlin your browser - Refresh to see new random colors
function getRandomColor(){
let val1 = Math.ceil(Math.random() * 255);
let val2 = Math.ceil(Math.random() * 255);
let val3 = Math.ceil(Math.random() * 255);
return `rgb(${val1}, ${val2}, ${val3})`;
}