Focus div to apply CSS style - Javascript jQuery

Javascript examples for jQuery:CSS

Description

Focus div to apply CSS style

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-1.7.1.js"></script> 
  <style id="compiled-css" type="text/css">

input {/*from  w  w w.  jav  a  2  s.c o  m*/
   width: 100px;
   height: 100px;
}


      </style> 
  <script type="text/javascript">
    $(window).load(function(){
$('input').focus(function() {
     $(this).css('background','green');
});
    });

      </script> 
 </head> 
 <body> 
  <input>  
 </body>
</html>

Related Tutorials