2
A
回答
1
像这样(用jQuery):
<!DOCTYPE html>
<html lang="en">
<head>
<title>LOL Focus!</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.3/jquery.min.js"></script>
</head>
<form>
<input class="focusable" type="text" value="lol"/>
<input class="focusable" type="text" value="lol" />
<input class="focusable" type="text" value="lol" />
<input class="focusable" type="text" value="lol" />
<input class="focusable" type="text" value="lol" />
<input class="focusable" type="text" value="lol" />
</form>
<input type="button" id="trigger_button" value="lol" />
<script type="text/javascript">
$(function() {
var focusable = $('.focusable'),
last_element_index = focusable.length - 1,
current_index;
focusable.each(function(i) {
$(this).click(function() {
current_index = i;
})
});
$('#trigger_button').click(function() {
current_index = (should_reset_current_index()) ? 0 : current_index + 1;
focusable[current_index].focus();
});
function should_reset_current_index() {
return (typeof(current_index) === 'undefined') || (current_index == last_element_index)
}
});
</script>
</html>
0
需要在一个前一阵子模仿的标签功能,现在我已经released it as a library使用jquery。
EmulateTab:一个jQuery插件,用于模拟页面上元素之间的Tab键。
您可以see how it works in the demo。
if (myTextHasBeenFilledWithText) {
// Tab to the next input after #my-text-input
$("#my-text-input").emulateTab();
}
相关问题
- 1. Flex 3:我怎样才能模拟被按下的输入/返回键
- 2. 我怎样才能在Android模拟器
- 3. 我怎样才能模拟Server.HtmlEncode
- 4. 我怎样才能找到元素
- 5. jquery:我怎样才能复制元素?
- 6. Tab键给出麻烦。我怎样才能阻止这
- 7. 我怎样才能赶上2+键按下?
- 8. 模拟Tab键在Flex上按下?
- 9. 我怎样才能停止成长div元素的子元素
- 10. 我怎样才能重置我的活动,按下按钮
- 11. 怎样才能居中元素
- 12. 我怎样才能关闭键盘上的输入按键
- 13. 我怎样才能
- 14. 我怎样才能
- 15. 我怎样才能
- 16. 我怎样才能
- 17. 元素'tab键按订单
- 18. 我怎样才能正确地模拟我的controllercontext测试ViewResult.ExecuteResult()?
- 19. 我怎样才能为每个外键
- 20. Redis:我怎样才能按键排序我的散列?
- 21. 我怎样才能找到HTML
- 22. 我怎样才能检查哪个提交按钮被按下?
- 23. 我怎样才能使周围按钮
- 24. 我怎样才能使按钮出现
- 25. 我怎样才能把differents元素放在我的arrayAdapter中?
- 26. 我怎样才能下载使用C++
- 27. 我怎样才能让下BackgroundWorker的
- 28. 我怎样才能在下拉
- 29. 我怎样才能让我的按钮在左下角?
- 30. 我怎样才能看到SQLite数据库(无模拟器)?
http://stackoverflow.com/questions/1803338/simulate-the-tab-key-function-in-javascript – 2010-06-18 21:51:23
的可能的复制DanC,你有没有发现该问题的解决方案?我有同样的任务。 Stephen P,这不是重复的,有些情况下很难找到应该关注的页面上的下一个活动元素。 – whitered 2010-12-22 09:19:28
Stephen P,不,我没有找到答案。我重构了我的代码,以便它可以或多或少地完成这项工作,但我无法模拟按Tab键的效果。 – DanC 2010-12-22 13:59:48