Javascript examples for jQuery:Form Input
Add Background color after setting content in input field
<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>