Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我单击一个随机按钮,有没有办法定义我的光标当前在哪个输入元素中?
如果单击按钮,光标将不再位于输入元素中。
但是,您可以执行以下操作:
<input onFocus="activeInput = this;" />
然后,当您单击按钮时,找到 的值activeInput并且您选择了输入元素。
activeInput