开发者_开发问答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')
精彩评论