gpt4 book ai didi

Javascript 不适用于移动设备,但适用于桌面,用于选项卡到四个 otp 框的下一个字段

转载 作者:行者123 更新时间:2023-11-30 06:12:28 24 4
gpt4 key购买 nike

let element = $event.srcElement.nextElementSibling;
element.focus()

此处下一个元素兄弟不起作用。

如果在框 1 中输入第一个数字,然后它会自动切换到下一个框,它在桌面浏览器中工作正常但在移动浏览器中不工作?

<input type="text" #otpvalue1 maxlength="1" [value]="otpValue1" (paste)="pasteEvent($event)" (keypress)="otpBox1($event)" (keydown)="handleBackSpaceBox1($event)"/>
<input type="text" #otpvalue2 maxlength="1" [value]="otpValue2" (paste)="pasteEvent($event)" (keypress)="otpBox2($event)" (keydown)="handleBackSpaceBox2($event)">
<input type="text" #otpvalue3 maxlength="1" [value]="otpValue3" (paste)="pasteEvent($event)" (keypress)="otpBox3($event)" (keydown)="handleBackSpaceBox3($event)">
<input type="text" #otpvalue4 maxlength="1" [value]="otpValue4" (paste)="pasteEvent($event)" (keypress)="otpBox4($event)" (keydown)="handleBackSpaceBox4($event)" />

otpBox1(obj) {
obj = (obj) ? obj : window.event;
let charCode = (obj.which) ? obj.which : obj.keyCode;
if ((charCode > 31 || charCode == 13) && (charCode < 48 || charCode > 57)) {
return false;
}
else {
this.otpValue1 = obj.key;
let otplength = this.otpValue1 + this.otpValue2 + this.otpValue3 + this.otpValue4;
this.otplength = otplength.length;
let element = obj.srcElement.nextElementSibling;
if (element != null) {
element.focus();
obj.preventDefault();
}
return true;
}
}


最佳答案

需要更多代码..你如何决定是否继续前进?触摸设备与插入键盘和鼠标控制的设备之间的许多事件非常不同!

关于Javascript 不适用于移动设备,但适用于桌面,用于选项卡到四个 otp 框的下一个字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58074263/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com