开发者

jquery trigger focus and cursor movement

开发者 https://www.devze.com 2023-04-12 03:12 出处:网络
开发者_开发问答Is there any way to trigger the focus() event on a <textarea> element and put the mouse cursor at the end of the text which is inside the textarea?

开发者_开发问答Is there any way to trigger the focus() event on a <textarea> element and put the mouse cursor at the end of the text which is inside the textarea?

thx


Was going to close as duplicate, but the other one doesn't cover how to trigger the focus.

See: Use JavaScript to place cursor at end of text in text input element for how to put the mouse cursor at the end

And to trigger the focus, you just need $('#foo').focus() or $('#foo').trigger('focus')

0

精彩评论

暂无评论...
验证码 换一张
取 消