How to get a link to a focused form field in JavaScript?

I am looking for a cross-browser method - I know that IE has something (I already forgot that), and the way to do it in Mozilla is probably related to the focusNode function I found, which seems to be related to select text.

The methods related to jQuery or another common JS library are fine with me.

Thanks!

+5
source share
2 answers

Open an optional selector plugin for jQuery, it includes a: focus selector that suits your needs. You can only use the implementation of this selector if you are not the rest.

+4
source

, jQuery.

, . , , ( Karl Rudd ) . , DOM.

var currentFocus = null; $ (': input'). focus (function() {   currentFocus = this; }). blur (function() {

currentFocus = null; 

});

+1

All Articles