Set the colour of a text in a textarea using html input tag - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea

Introduction

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <form name="myform">
         Select Color : 
         <input type="color" onchange="Color(this)"> 
      </form> 
      <textarea name="myTextArea" id="myTextArea" cols="100" rows="14" placeholder="Enter Text Here ...">Test text..</textarea> 
      <script type="text/javascript">
function Color(obj) {/*w  ww. j a v  a2 s  .c om*/
    document.getElementById("myTextArea").style.color = obj.value;
}

      </script>  
   </body>
</html>

Related Tutorials