Add Background color after setting content in input field - Javascript jQuery

Javascript examples for jQuery:Form Input

Description

Add Background color after setting content in input field

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://code.jquery.com/jquery-2.2.4.js"></script> 
      <script type="text/javascript">
    window.onload=function(){/*  ww w .ja  v a2s  .c  om*/
$( "#target" ).blur(function() {
  $( "#target" ).css('background-color','red');
});
    }

      </script> 
   </head> 
   <body>
       First name: 
      <input type="text" name="firstname" id="target">  
   </body>
</html>

Related Tutorials