我试图在按 TAB 键后将焦点设置到特定文本框。页面上只有一个文本框。看起来很简单。
$("#status").keydown(function (e) {
if (e.which == 9) {
$("#statuses").html(this.value);
this.value = "";
$("#status").focus();
}
});
这是我的 jsFiddle 示例:
http://jsfiddle.net/7Rfqa/ http://jsfiddle.net/7Rfqa/
如果我为 ENTER 按钮编码它工作正常,但对于 TAB 它只是转到 URL 栏。
您需要停止默认行为,试试这个
$("#status").keydown(function (e) {
if (e.which == 9) {
$("#statuses").html(this.value);
this.value = "";
$("#status").focus();
e.preventDefault();
}
});
Fiddle:
http://jsfiddle.net/7Rfqa/1/ http://jsfiddle.net/7Rfqa/1/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)