关于 ios 限制 input 自动聚焦的解决办法

ios 系统禁止 input 自动聚焦,所以 DOM.focus() 方法并不生效,通过查阅资料,可以给 input 一个 click 事件,并在其中触发 focus 事件即可。再给 input 触发 click 事件。代码如下:


    $(element).on('click',function(){

      $(element).focus();

     })

    setTimeout(function() {

      $(element).trigger('click');

     }, 100);

    

鼎云博客
  • 最新评论
  • 总共1条评论
鼎云博客

游客:150.138.138.*:弟弟

2020-05-14 13:31:21 回复