document.selection.createRange method and examples_javascript skills
WBOYOriginal
2016-05-16 19:25:141517browse
Together with execCommand, it is very useful in HTML editors, such as bolding text, italics, copying, pasting, creating hyperlinks, etc.
This is good
There is a piece of text in the text field. When you select a few words and click a button or link, a dialog box will pop up. The information in the dialog box is the text you selected.
Which boss can solve it? Please help me!!! Thank you
There is a piece of text in the text field. When you select a few words and click a button or link, a dialog box will pop up. The information in the dialog box is the text you selected.
Which boss can solve it? Please help me!!! Thank you
After selecting the content in the textarea, add effects
Select me and click bold [Ctrl A Select all Note:
If you need to introduce external Js, you need to refresh to execute ]
Example 4: javascript capture Plain text content in the selected web page
Mouse to pick words
The above code can capture the plain text content (without HTML tags) in the selected web page
If you want to get content containing html, change document.selection.createRange().text to document.selection.createRange().htmlText
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn