For example, if you open a page and click on a text-box element, it will take the focus and hence calling the hasFocus() method will return the value true as a result.
document hasFocus() Method Syntax:
document hasFocus() Method Parameters
The method does not take an argument.
document hasFocus() Method Return Value
The return value of this method is a boolean type and will be true if the document or any of its elements have the focus or false if the document or any of its element didn’t have the focus.
How does document hasFocus() method work?
The moment we click the button on the page, the element and the document get the focus and so the result of calling the `hasFocus()` method will return true.