Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
179
rated 0 times [  181] [ 2]  / answers: 1 / hits: 37894  / 9 Years ago, mon, june 8, 2015, 12:00:00

Using jQuery, I can test if an input field has focus like so:



if ($(...).is(:focus)) {
...
}


How do I do that without using jQuery?


More From » html

 Answers
12

This question was answered here: Javascript detect if input is focused



Taken from the above answer:



this === document.activeElement // where 'this' is a dom object

[#66285] Friday, June 5, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
tristab

Total Points: 735
Total Questions: 106
Total Answers: 96

Location: Grenada
Member since Sun, Dec 20, 2020
3 Years ago
tristab questions
Sat, Sep 25, 21, 00:00, 3 Years ago
Sun, Jan 31, 21, 00:00, 3 Years ago
Wed, Dec 2, 20, 00:00, 4 Years ago
Fri, Oct 23, 20, 00:00, 4 Years ago
;