msm*_*fra 5 jquery events tabs enter form-submit
我已经阻止了Enter(返回)键,实际上,它在Tab键中被转换了.因此,当在输入文本字段内按下时,它将充当Tab键.这很好,但我需要它在最后一个字段中按下时触发提交按钮,下面是Enter键变异的代码:
$('input').keydown(function(event) {
if(event.which == 13) {
event.preventDefault();
$(this).nextAll('input:first').focus();
}
});
Run Code Online (Sandbox Code Playgroud)
和形式码是一序列输入类型="文本"和一个按钮式="提交"在端[编辑]实际上代码是这其中,从拍摄的jquery:在特定部分输入到标签触发.但我不知道为什么今天昨天工作不起作用:
$(':text').keydown(function(e) {
if(e.keyCode == 13 && $(this).attr('type') != 'submit') {
e.preventDefault();
$(this).nextAll('input:first').focus();
}
});
Run Code Online (Sandbox Code Playgroud)
如果你给上一个输入最后一个类,那么只需修改你的代码即可
$('input').keydown(function(event) {
if(!$(this).hasClass("last")){
if(event.which == 13) {
event.preventDefault();
$(this).nextAll('input:first').focus();
}
}
});
Run Code Online (Sandbox Code Playgroud)