Home >Web Front-end >JS Tutorial >document.selection.createRange method and examples_javascript skills

document.selection.createRange method and examples_javascript skills

WBOY
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.


[Ctrl A to select all Note: If you need to introduce external Js, you need to refresh to execute ]


This is good


[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]



Example 3: Select the text in Input
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 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