Could anyone tell how to select portion of text in textarea and copy it to clipboard by using javascript? I know how to select all text in textarea and copy it? My question is that when we use mouse to select part of text in textarea, how to copy it to clipboard.
How about this
(on)select save the start and end position of the selection to the input element itself.
event.target.lastSelection = { start:startpos, end:endpos};
and use the (on)blur event to do something like
event.target.setSelectionRange( event.target.lastSelection.start, event.target.lastSelection.end )?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.