Home >Web Front-end >JS Tutorial >Copy a table on a web page through JavaScript script_javascript skills

Copy a table on a web page through JavaScript script_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-05-16 19:28:091045browse


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

This function is realized , but I feel a little unhappy because I have to use the HTML editor. However, from the code of the HTML editor, I noticed the createTextRange() method. This method has been used before, but I have never studied it in depth. In Msdn, I found that only objects such as Body and TextArea support the createTextRange() method. I continued to check it carefully in msdn. CreateTextRange() returns a TextRange object. I continued to check the TextRange object and found that it has many methods. I gave it a try first. findText method, I found that only text can be selected, but objects cannot be selected. I continued to search, and finally found that moveToElementText is the method we are looking for:
Text
[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute ]
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