How can I get the character positions of the selected text in an HTML <input>
textbox element? window.getSelection()
doesn't work inside textboxes.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- Carriage Return (ASCII chr 13) is missing from tex
- void before promise syntax
If you're using jQuery, take a look at the jQuery Caret plugin: jCaret
........
Reference: http://www.codetoad.com/javascript_get_selected_text.asp
In case you don't need to support really old versions of Internet Explorer, just use the element's
selectionEnd
andselectionStart
properties.