admin管理员组文章数量:1356741
I was almost sure I could find the answer here, but I wasn't successful.
How would you check whether is there some object selected (focused) on the moment of the event call? I tried if (document.activeElement == "[object HTMLBodyElement]")
, but apparently the .activeElement
is being filled onLoad. I am not allowed to use jQuery, only mootools.
Thanks a lot for the help!
I was almost sure I could find the answer here, but I wasn't successful.
How would you check whether is there some object selected (focused) on the moment of the event call? I tried if (document.activeElement == "[object HTMLBodyElement]")
, but apparently the .activeElement
is being filled onLoad. I am not allowed to use jQuery, only mootools.
Thanks a lot for the help!
Share Improve this question asked Aug 13, 2011 at 18:53 mrkvamrkva 3342 silver badges13 bronze badges2 Answers
Reset to default 5https://developer.mozilla/en/DOM/document.activeElement - as pointed out, if no element is focused, the document body is focused by default:
if (document.activeElement != document.body) {
// something else than the body is focused
}
if ( document.body === document.activeElement ) {
// the body is focused, ie no other element is focused
}
本文标签: javascriptCheck whether some element is quotfocusedquot without jQueryStack Overflow
版权声明:本文标题:javascript - Check whether some element is "focused" without jQuery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744041763a2580781.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论