简体   繁体   English

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

[英]Javascript not working on mobile but works on desktop for tab to next field for four otp box

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

Here next element sibling is not working.这里下一个元素兄弟不起作用。

if enter 1st number into box 1 then it tab to next box automatically, it working fine in desktop browser but not in mobile browser?如果在框 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;
    }
  }


more code needed.. how are you deciding wether or not to jump ahead?需要更多代码..您如何决定是否继续前进? many events are very different between touch devices and those controlled by a plugged in keyboard and mouse!许多事件在触摸设备和那些由插入的键盘和鼠标控制的设备之间是非常不同的!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Javascript 不适用于移动设备,但适用于桌面设备 - Javascript not working on mobile but works on desktop JavaScript 选项卡不会在移动设备上切换,但在桌面上运行良好 - JavaScript tab doesn't toggle on mobile but works fine on desktop Href Javascript可在台式机上使用,但不能在移动设备上使用 - Href Javascript works on desktop but not on Mobile Javascript 代码适用于桌面,但不适用于移动设备 - Javascript code works on desktop but not on mobile Javascript 适用于桌面,但不适用于移动浏览器 - Javascript works on desktop but not on mobile browser 标签结构适用于台式机,但不适用于移动设备 - Tab structure working for desktop but not working for mobile devices 当我点击提交按钮我的javascript第一个警报框显示在移动设备但在桌面上工作正常 - when I click on submit button my javascript first alert box show in mobile device but works fine in desktop Javascript函数在桌面上可用,在移动浏览器上失败 - Javascript function works on Desktop, fails on mobile browser jquery facebook分享不工作移动但在桌面上工作 - jquery facebook share not working mobile but works on desktop 地理位置无法在移动设备上使用,但可以在我的台式机上使用 - The geolocation isnt working on mobile but works on my desktop
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM