Table of Contents

How to choose background color through a color picker?

In this article, I will show to change background color through a color picker. I think this will help you

HTML & JS Code

<label for="clr"> Background Color </label>
<input type="color" id="clr" class="form-control mt-2">

<div id="background" style="height:50px; width:100px"></div>

<script>

        
         const bgclr = document.getElementById("clr"); // color selector
         const headingg = document.getElementById("background");

         bgclr.addEventListener("input", () => {
               document.body.style.backgroundColor = bgclr.value;
               headingg.style.background = bgclr.value;
                
          });

 </script>
 

Share on facebook
Facebook
Share on twitter
Twitter
Share on linkedin
LinkedIn

Leave a Comment

Your email address will not be published.

Related Posts