gpt4 book ai didi

javascript - 聚焦动态创建的元素

转载 作者:搜寻专家 更新时间:2023-11-01 05:02:45 25 4
gpt4 key购买 nike

如何聚焦动态创建的元素?

最佳答案

只需调用 .focus()添加到 DOM 后的元素上,例如:

var input = document.createElement("input"); //create it
document.body.appendChild(input); //append it
input.focus(); //focus it

You can test it out here .

关于javascript - 聚焦动态创建的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4183325/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com