Style Form Input Fields With Background Color Style - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Input Color

Description

Style Form Input Fields With Background Color Style

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <input type="text" id="demoInput" onfocus="demoFocus(this.id)" onfocusout="demoFocusout(this.id)"> 
      <script>
function demoFocus(x) {//  w  w  w.ja  v a 2 s .  c  om
    document.getElementById(x).style.background = "red";
}
function demoFocusout(x) {
    document.getElementById(x).style.background = "blue";
}

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

Related Tutorials