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
functiongetRandomColor(){letval1=Math.ceil(Math.random()*255);letval2=Math.ceil(Math.random()*255);letval3=Math.ceil(Math.random()*255);return`rgb(${val1}, ${val2}, ${val3})`;}