如何模拟按键按键? [英] How can I simulate a tab key press?

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

问题描述

我有一个网页,其中javascript例程将表格交换为清除屏幕并开始一组新问题。清除屏幕后,文本框或下拉菜单只需通过ID获取元素即可获得焦点,以.focus()结尾。没问题。但是,如果屏幕上的第一个对象是单选按钮,则除非按下Tab键,否则它将不会接受焦点。如何模拟Tab键按下以使radiobutton可以获得焦点?

解决方案

您可能必须首先测试您正在使用的表单元素类型,但是这样可能有所帮助:

http:// bytes。 com / groups / javascript / 9 ... s-radio-button


正如所说这里当元素被正确检索时已经集中了......但IE只是没有显示你认为...


我能想到的唯一解决方案就是用JavaScript改变radiobutton的风格,以解决IE的这个问题,或者重新排序节点以便放射线按钮不是第一个集中注意力的节点 - 如果可能的话。


亲切的问候


Ag ain,我怎样才能模拟一个标签键按下???


这个其他的东西不起作用。你仍然需要按下用于无线电按钮的标签键来获得焦点。


那么,如何模拟标签键按????????????? ?

I have a webpage where a javascript routine swaps tables to "clear" the screen and start a new group of questions. After the screen is cleared a textbox or a drop-down menu can receive focus by simply getting the element by ID, ending in .focus(). No problem. However, if the first object on a screen is a radiobutton it will not accept focus unless there is a tab key press. How can I simulate a tab key press so the radiobutton can receive focus?

解决方案

You might have to test what type of form element you are working with first, but this might help:

http://bytes.com/groups/javascript/9...s-radio-button


as was said here already the element IS focused when it is retrieved correctly ... but IE just don''t show you that ...

the only solution i could think of is to change the style of the radiobutton accordingly with JavaScript to workaround this problem with IE or to reorder the nodes so that the radiobutton is not the first node to get focussed - in case that would be possible.

kind regards


Again, how can I simulate a tab key press???

This other stuff doesn''t work. You still have to press the tab key for the radiobutton to receive focus.

So, how can I simulate a tab key press??????????????


这篇关于如何模拟按键按键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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