H5 input 聚焦 置顶

复制代码
myFocus (e) {
this.active = true

  function getElementTop(element){
try {
     var actualTop = element.offsetTop;
     var current = element.offsetParent;
     while (current !== null){
       actualTop += current.offsetTop;
       current = current.offsetParent;
     }
     return actualTop;
} catch (e) {}
   }

setTimeout(() => {
window.scrollTo(0, getElementTop(e.target));
}, 150)
},
复制代码

 

posted @   贝尔塔猫  阅读(329)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示