<input type="text" class="txt" maxlength="5" placeholder="1"/>
<br/>
<input type="text" class="txt" maxlength="5" placeholder="2"/>
<br/>
<input type="text" class="txt" maxlength="5" placeholder="3"/>
<script>
var txt = document.getElementsByClassName("txt");
for(var i=0;i<txt.length;i++){
txt[i].onkeyup = function(){
if(this.value.length == 5){
this.blur();
txt[i+1].focus();
};
};
}
</script>
需求是这样的:在输入框输入内容之后,自动将焦点定位到下一个input上
眼眸繁星
相关分类