如何聚焦动态创建的元素?
最佳答案
只需调用 .focus()
添加到 DOM 后的元素上,例如:
var input = document.createElement("input"); //create it
document.body.appendChild(input); //append it
input.focus(); //focus it
关于javascript - 聚焦动态创建的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4183325/