P粉6626142132023-08-22 14:16:10
.focus()
Then select any other element .blur()
on your page. Since only one element can have focus, focus is transferred to that element and then removed.
P粉3480889952023-08-22 12:57:31
Answer: document.activeElement
To achieve the effect you want, use document.activeElement.blur()
If you need to support Firefox 2, you can also use the following code:
function onElementFocused(e) { if (e && e.target) document.activeElement = e.target == document ? null : e.target; } if (document.addEventListener) document.addEventListener("focus", onElementFocused, true);