87,914
社区成员
发帖
与我相关
我的任务
分享
<form>
<input type="text" name="num2" maxlength="3">
<input type="text" name="num2" maxlength="3">
<input type="text" name="num2" maxlength="3">
<input type="text" name="num2" maxlength="3">
<input type="text" name="num2" maxlength="3">
</form>
window.onload = function(){
var dom = document.querySelectorAll('input');
for(var i=0; i<dom.length; i++){
dom[i].addEventListener('input',function(){
if(this.value.length == this.maxLength){
this.blur();
this.nextElementSibling && this.nextElementSibling.focus();
}
})
}
}