What I would like to achieve now is...">

Add inmidatley user login to <input>

In this example, I have a simple html markup:

<input id="INPUT"/>

What I would like to achieve now is that the user enters something. His inmidiatley entry is featured in #INPUT. I tried this, but somehow this does not work:

$('document').keydown( function(e) {
   $('#INPUT').focus();
});

What should I do instead? thanks http://jsfiddle.net/GdVvd/

+3
source share
6 answers

You don't need quotes around document, since the selector will look for an element that has the tagNamecorresponding “document” if you put it in quotation marks.

Live demo

$(document).keydown( function(e) {
   $('#INPUT').focus();
});
+6
source

HTML5 input autofocus. , :

<input id="input" autofocus />

JSFiddle.

, IE Firefox.

+1

, :

$(document).keydown( function(e) {
   $('#INPUT').focus();
});

JSFIDDLE

+1

:

$(document).keydown( function(e) {
   $('#INPUT').focus();
});
+1

" ".

$(document).keydown( function(e) {
   $('#INPUT').focus();
});

http://jsfiddle.net/GdVvd/

+1

js , , single quotes document. , . , .

//var keycodes = [];
$(document).keydown( function(e) {
   if(e.which == 'somekeycode')
     $('#INPUT').focus();
});
0

All Articles