查找当前是否选择了文本框 [英] Find if a textbox is currently selected
本文介绍了查找当前是否选择了文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案
因为您已经找到 document.activeElement
,你可以检查它的nodeName。
if(document.activeElement.nodeName =='TEXTAREA'|| document.activeElement.nodeName =='INPUT'){
// ....
}
类似的东西。
How would I find if a textbox (or textarea) currently is in focus? I don't care to know which one it is, I just need to know if one is in focus (has the cursor in it). How would I do this with javascript and jquery?
解决方案
Since you have found document.activeElement
, you can check its nodeName.
if (document.activeElement.nodeName == 'TEXTAREA' || document.activeElement.nodeName == 'INPUT') {
// ....
}
Something like that.
这篇关于查找当前是否选择了文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文