这是我的login.jsp
页面,当我在第一个文本字段中输入用户名并且从键盘输入 Enter 键时,我有2个文本字段,它不会进入下一个文本字段。我怎样才能做到这一点?谢谢你的帮助。
<body>
<div id="wrapper">
<table width="90%" border="0" align="center" cellpadding="0" cellspacing="0" >
<tr>
<td width="15%"><input name="username" type="text" id="username" value="username"/></td>
<td><input name="password" type="password" id="password" value="password"/></td>
</tr>
<tr><td>
</td></tr>
<tr>
<td align="right" valign="bottom" ><input type="button" name= "button" id= "button" value= "Submit" /></td>
</tr>
</table>
</div>
答案 0 :(得分:0)
网络浏览器的两个选项:
您可以使用输入键所在的标签键重新编程键盘;);)
答案 1 :(得分:0)
要将焦点更改为其他输入文本,人们通常会点击标签而不是输入..
但是你可以用jquery事件处理程序来实现..
$( "#your-username-input" ).keypress(function( event ) {
//press enter button
if ( event.which == 13 ) {
$( "#your-other-input" ).focus();
}
答案 2 :(得分:0)
$(“#username”)。on('keydown',function(event){
if(event.which == 13) {// Enter key pressed
event.preventDefault();
/* $this = $(this);
$this.focus();
var value = $this.val();
$this.val(''); // clear the field
// do stuff with the value*/
}
});
密码
也是如此