DEV Community

Cover image for Color Flipper Using RGB color
Piyush Jain
Piyush Jain

Posted on

Color Flipper Using RGB color

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.

Top comments (0)