gpt4 book ai didi

javascript - 使用 JavaScript 或 jQuery 将焦点设置为动态创建的 DIV

转载 作者:行者123 更新时间:2023-11-30 14:17:16 25 4
gpt4 key购买 nike

我创造了

Generated code : 

<div id="showInfo_1" style="display: none">
--info 1
</div>

<div id="showInfo_2" style="display: none">
--info 2
</div>

jQuery : $('showInfo_2').focus();

这在 Chrome 中可以正常工作,但在 IE 中不行。

接下来我可以尝试什么?

最佳答案

Attempting to set focus to a hidden element causes an error in Internet Explorer. Take care to only use .focus() on elements that are visible. To run an element's focus event handlers without setting focus to the element, use .triggerHandler( "focus" ) instead of .focus().

来自:https://api.jquery.com/focus/

关于javascript - 使用 JavaScript 或 jQuery 将焦点设置为动态创建的 DIV,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53379880/

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