A Pen by Muhammad

Thumbnail
This awesome code was written by inelei, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright inelei ©
  • HTML
  • CSS
  • JavaScript
    <html>
  <head>
    <title>Lesson 3</title>
  </head>
  <body>
    <h1>Color choose</h1>
    
    <canvas id="canvas"></canvas>
    
    <div>
      <input type="button" value="Set color" onclick="defaultColor()" />
      <input type="color" value="#ff8000" id="col" onchange="setColor()" />
    </div>
  </body>
</html>

/*Downloaded from https://www.codeseek.co/inelei/a-pen-by-muhammad-jyRMBb */
    canvas {
  border: 1px solid Grey;
  width: 200px;
  height: 100px;
}


/*Downloaded from https://www.codeseek.co/inelei/a-pen-by-muhammad-jyRMBb */
    function defaultColor() {
  var canvas = document.getElementById("canvas");
  canvas.style.backgroundColor = "#ff8000";
}
function setColor() {
  var canvas = document.getElementById("canvas");
  var colorPic = document.getElementById("col");
  canvas.style.backgroundColor = colorPic.value;
}

Comments