开发者

Retain user selected text on blur/focus

开发者 https://www.devze.com 2023-02-12 19:37 出处:网络
How can I retain the user\'s text selection when calling $(inputElement).focus() on some text input element, inputElement, so that they can still use Ctrl+C after inputting some text top their initial

How can I retain the user's text selection when calling $(inputElement).focus() on some text input element, inputElement, so that they can still use Ctrl+C after inputting some text top their initial selection?

I have considered intercepting the $(document).blur(...) event and preventing propagation to keep the selected text, but I'm not sure if it will work across all major browsers, if at 开发者_StackOverflowall.


if i didn't misunderstood...

you can use window.storage or document.cookie(in case window.storage is un available)... when the user input text in the field you can store its value(onBlur) against an id and on ctrl+C retrieve the value and put it else where (in case of ctrl+z)

0

精彩评论

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

关注公众号