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.
有什么方法可以触发元素focus()上的事件<textarea>并将鼠标光标放在文本区域内的文本末尾?
focus()
<textarea>
谢谢
将作为重复关闭,但另一个不包括如何触发焦点。
请参阅:使用 JavaScript 将光标置于文本输入元素中的文本末尾以了解如何将鼠标光标置于末尾
要触发焦点,您只需要$('#foo').focus()或$('#foo').trigger('focus')
$('#foo').focus()
$('#foo').trigger('focus')