Home > Web Front-end > JS Tutorial > body text

Summary of some cursor operations_javascript skills

WBOY
Release: 2016-05-16 19:25:23
Original
1197 people have browsed it

The Range operation under IE is much better than that under Mozilla. Here we only discuss the operation under IE.
Here are a few features of cursor positioning:

1. The cursor remains unchanged

Direct obj.focus(), the cursor will return to the previous position. That is, the position remains unchanged

2. The cursor is at the front

Copy code The code is as follows:

var r = obj.createTextRange();
r.collapse();
r.select();

Use this The method can put the cursor at the front of the input box

3. The cursor is at the end

Copy code The code is as follows:

var r = obj.createTextRange();
r.collapse(false);
r.select();

Use this method to make the cursor stop at the end of the input box

4. To select part of the content in the input box, you need to use the moveStart or moveEnd method of Range. For detailed methods, please refer to MSDN.


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

5. Let’s expand on the movement and position of the cursor. This is a question that people often ask

[Ctrl A select all Note:
If you need to introduce external Js, you need to refresh to execute ]
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template