DEV Community

loading...
Cover image for Color Flipper Using RGB color

Color Flipper Using RGB color

Piyush Jain
Teacher Become Developer, Really Nice Journey. Fast Learner, Dedicated Person.
・1 min read

Hello Dev Friends,

Today i am showing how you can flip background color of screen infinitely using simple javascript, html and CSS.

  • Html

    • Create Simple Span to show which Color is Present
    • A button which changes the color
  • Javascript

    • Add event listener on button
      • in this function generate a random number between 0 to 256(rgb values).
    • We know that body.background-color in RGB format accept 3 values as number so we need to generate 3 number randomly.
    • Put these 3 numbers in rgb() by using string concat or template.

For More Information you can visit my GitHub Code :-
https://github.com/piyushmbm45/JavaScriptProject/tree/master/color%20flipper

There You will find other color flippers also.

Thanks guys.

Discussion (0)