When we use old JavaScript (without any frameworks) this is what we get:
Var focusedElement;
document.addEventListener("focus", function(e) {
focusedElement = e.target;
}, true);
document.addEventListener("blur", function(e) {
focusedElement = null;
}, true);
Whenever an element gains focus, then we save that element to a variable, and when the element loses focus, we reset the variable.
Does this help?
Var focusedElement;
document.addEventListener("focus", function(e) {
focusedElement = e.target;
}, true);
document.addEventListener("blur", function(e) {
focusedElement = null;
}, true);
Whenever an element gains focus, then we save that element to a variable, and when the element loses focus, we reset the variable.
Does this help?