Javascript Code to Store Last Active Element that can Accept User Input

Javascript Code to Store Last Active Element that can Accept User Input ie input element, textarea or select element

Home Short:

Javascript has the activeElement property which stores the last active element of a document but sometimes you need to only be concerned only with elements that can accept user input such as any input element, textarea or select element. After all, why would it be important to put focus back on an element that can't accept user input such as an h1 or paragraph element?

S
H
A
R
E