Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Random Background Color Changer

A tiny vanilla-JS demo that changes the page background to a new random colour each time the Change Background Color button is pressed. Useful as an introductory exercise in DOM manipulation and event handling.

Project structure

/
├─ index.html              # markup with a button and colour read-out
├─ backColorChanger.css    # minimal styling
└─ backColorChanger.js     # JS logic that generates and applies colours

How it works

  1. HTML displays a heading, a <p> element that shows the current hex code, and a button.
  2. JavaScript attaches a click-listener to the button.
  3. On each click a six-digit random hex value is generated, the <body> background colour is updated, and the new hex code is written to the <span id="bg-hex-code">.

Running locally

No build step is required.

# clone or download this repo
cd random-background-color-changer
# simply open index.html in a browser

Potential extensions

  • Copy the hex code to clipboard when clicked.
  • Add RGB / HSL display modes.
  • Animate smooth transitions between colours.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages