在Javascript中查找复选框是否被聚焦 [英] In Javascript find if a checkbox is focused
本文介绍了在Javascript中查找复选框是否被聚焦的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Javascript中如何判断一个复选框是否有焦点?
In Javascript how can I tell if a checkbox has focus or not?
我认为会有一个名为isfocused的方法或属性。但显然不是。
I thought there would be a method or property called isfocused. But apparently not.
通过焦点我的意思是他们使用键盘选项卡,在这一点按空格将检查框。
By in focus I mean they've tabbed to it using the keyboard and at this point pressing space would check the box.
推荐答案
创建一个连接到onfocus事件的事件处理程序。当它被调用时,设置一个全局var来记住它的焦点。在清除变量的onblur事件上写另一个。
Create an event handler that is wired to the onfocus event. When it's called, set a global var to remember that it's got the focus. Write another one on the onblur event which clears the variable.
这篇关于在Javascript中查找复选框是否被聚焦的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文