Autofocus to input when user starts typing on window - Javascript jQuery

Javascript examples for jQuery:Form Input

Description

Autofocus to input when user starts typing on window

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.2.min.js"></script> 
      <script type="text/javascript">
    window.onload=function(){//w w  w. j  a v  a 2  s  .  c om
$(window).keypress(function()
{
   $("#field").focus();
});
    }

      </script> 
   </head> 
   <body> 
      <input id="field" type="text">  
   </body>
</html>

Related Tutorials