如何确定哪个html页面元素具有焦点? [英] How to determine which html page element has focus?
本文介绍了如何确定哪个html页面元素具有焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能重复:
如何找出哪个DOM元素具有焦点?
Possible Duplicate:
How do I find out which DOM element has the focus?
有没有一种方法可以确定哪个html页面元素具有焦点?
Is there a way in javascript to determine which html page element has focus?
推荐答案
使用 document.activeElement
属性
document.activeElement $ c $在Chrome2 +,Firefox3 +,IE4 +,Opera9.6 +和Safari4 +上支持c>属性。
请注意,此属性将仅包含接受击键的元素(如表单元素)。
Note that this property will only contain elements that accept keystrokes (such as form elements).
这篇关于如何确定哪个html页面元素具有焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文