Detect which form input has focus using JavaScript or jQuery

document.activeElement, it’s been supported in IE for a long time and the latest versions of FF and chrome support it also. If nothing has focus, it returns the document.body object.

Leave a Comment