在Tab键上按GetTextBox ID [英] GetTextBox ID on Tab-key press

查看:85
本文介绍了在Tab键上按GetTextBox ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我在一个页面中有多个TextBoxes.
Tab键用于从一个TextBox导航到另一个TextBox.
当用户按下Tab键时,我需要获取光标所在的TextBox的ID(在javascript中).

我可以得到Tab键按下事件.
但是,如何在按Tab键时获取Textbox-ID(光标所在的位置).
有人可以帮我解决这个问题吗?

Hi I have a multiple TextBoxes in a page.
Tab-key is using to navigate from one TextBox to other TextBox .
when user press tab-key I need to get the the ID the TextBox (in javascript) in which the cursor exist.

I can get the Tab-key press event.
But How can I get the Textbox-ID(where cursor is) on Tab-key press.
Can anyone help me to resolve this?

推荐答案

JAJANCHERIAN,

我认为无需获取文本框ID.您可以将文本框对象直接发送到您的函数.
例如:
Hi SHAJANCHERIAN,

I think no need to get Textbox id. you can sent the text box object directly to your function.
for example:
<script type="text/javascript">
function gettextboxobject()
{

}
</script>

<input type="text" id="textbox1" onblur="gettextboxobject(this)"  önfocus="gettextboxobject(this)" />


您可以直接获取文本框对象.

如果需要更多内容,请回复.


you can get the textbox object directly.

please reply if you want more.


您可以尝试查看DOM元素document.activeElement.据我所知,它不能在所有浏览器中一致地工作,但是它应该可以帮助您入门.

从这里开始,
You can try taking a look at DOM Element document.activeElement. As far as I remember, it doesn''t work consistently across browsers, but it should get you started.

From here on, Google[^] is your friend. I''m sure you''ll find something to help you


这篇关于在Tab键上按GetTextBox ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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