如何检测文本框是否具有焦点? [英] how to detect if the text box has focus ?

查看:92
本文介绍了如何检测文本框是否具有焦点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好,
我的网络表单中有很多文本框,并且我想通过单击或使用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 the onFocus attribute inside the TextBox and run Js when onFocus 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆