Create HTML5 input type color element and set value - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Color

Description

Create HTML5 input type color element and set value

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <script>
    var i = 0;
    var inp=document.createElement("input");
    inp.setAttribute('type','color');
    inp.setAttribute('id','colo_'+i);
    inp.value = '#ffffff';
    inp.setAttribute('class','datafield');
    document.body.appendChild(inp);
  
      </script>  
   </body>//from   w w  w  .j  a va 2 s .c  o m
</html>

Related Tutorials