我如何知道哪个元素具有焦点?
我如何知道哪个元素拥有焦点,或者如何确定某个元素是否获得焦点?
How do I know which element has the focus, or how to determine whether the focus of a particular element?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不知道如何直接查询此类信息。我想你可以遍历 DOM 并手动检查它。如果是这种情况,您应该看看这个< /a>.
也许您想要做的事情可以通过在感兴趣的特定元素获得焦点时处理事件来实现。以下是在 jQuery 中如何做到这一点。
只是为了咯咯笑,这是一种可以使用 focus 方法来跟踪哪个元素最后收到它的方法。我强烈建议不要使用此代码。
I don't know of anyway to query for this kind of information directly. I suppose you could traverse the DOM and check for it manually. If that's the case you should look at this.
Perhaps what you are trying to do can be achieved by handling an event when specific elements of interest gain focus. Here is how you would do that in jQuery.
Just for giggles, here is one way you could use the focus method to track which element recieved it last. I highly recommend against using this code.
恐怕尚未实施。
你可以这样做
,但 Windows 中的问题是控件窃取了 Shoes 的所有事件。
在绿鞋中它会起作用。如果您在 Windows 中,单击 edit_line 的右侧仍然可以看到结果。当然,这只是当您用鼠标单击时,您应该检查 keypress 以获取键盘事件。
格茨
not yet implemented yet i'm afraid.
You could do something like this
But the problem in windows is that the controls steal all the event from Shoes.
In Green Shoes it would work. If you'r in windows you can still see the result if you click just to the right of the edit_line. Of course, this is only when you click with the mouse, you should check keypress tot get the keyboard events also.
Grtz