如何检测文本框是否具有焦点? [英] how to detect if the text box has focus ?
本文介绍了如何检测文本框是否具有焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好,
我的网络表单中有很多文本框,并且我想通过单击或使用Tab键来检测具有焦点的文本框的ID.
Hello,
I have many textboxes in my webform and i want to detect the id of the textbox which has the focus, whether by clicking or by using tab key.
推荐答案
将onFocus
归入TextBox
内部,并在onFocus
触发时运行Js
.
即
put theonFocus
attribute inside theTextBox
and runJs
whenonFocus
triggeres.
i.e.
TempTextBox.Attributes.Add("onFocus", "DoFocus(this);");
现在把Js
换为DoFocus
Now the put the Js
for DoFocus
function DoFocus(this)
{
}
现在对象this
是您的TextBox
对象,现在可以根据需要使用它.
如果有帮助,请 投票 和 接受答案 .
Now object this
is your TextBox
object now play with it as you want.
Please vote and Accept Answer if it Helped.
这篇关于如何检测文本框是否具有焦点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文