js控制input获取焦点: $('input').focus(); 无效: 写在延迟函数中问题解决: setTimeout(()=>{ $('input').focus(); }) 可能原因:浏览器对dom的操作是等待代码执行完毕后进行。