-1

Say you have an HTML page of input elements with JavaScript connected to the input elements. You have the ability to press the TAB key, which by default browser behavior will highlight select the input element. Pressing TAB key again will then highlight select the next input element that is declared in the source code.

My question is, in JavaScript, how can I check if a specified input element is currently highlight selected?

I have tried researching this on my own prior to this post, but didn't find anything.

1 Answers1

-1

Thank you for the document.activeElement solution. Albeit, after trying it for my situation it didn't work. The solution I later discovered was the following:

e.stopImmediatePropagation();

The problem was that I had a specific event occurring that was mistakenly invoking more than one event listener. The listeners were working against each other. Originally I had thought if I could only detect which element is active that could fix it, but turns out it didn't. Later I found the solution I referenced that will immediately terminate all additional queued event listeners of a particular element when the code reaches the code I referenced.