Html input, always in focus

后端 未结 4 1639
梦谈多话
梦谈多话 2021-01-11 19:14

How can I keep the html input always in focus? Using the autofocus attribute when creating the element helps to focus at pageload, but it does not keep the focu

4条回答
  •  粉色の甜心
    2021-01-11 19:36

    For FIREFOX, Try using setTimeOut, it works :

    My JS :

    myFocusFunction(){
          let myInput = document.getElementById('idOfInput');
          setTimeout(function() { 
               myInput .focus(); 
          }, 100);
    }
    

    my Html :

    
    

提交回复
热议问题