Home >Web Front-end >JS Tutorial >Get the cursor position of div edit box, textarea, input text. Introduction to methods compatible with IE, FF and Chrome_javascript skills

Get the cursor position of div edit box, textarea, input text. Introduction to methods compatible with IE, FF and Chrome_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:48:271081browse

After 2 hours of searching online, none of them are compatible with FF. It seems that this kind of thing is not readily available online, so I have to make it myself.
Now that it is released, it will be available online for people to use in the future.

In order to save trouble, jquery is used in a few places. It is also very convenient to modify the native JS. If you need it, please modify it yourself.
Everyone is welcome to pass by the expert to make a decision, and you are welcome to leave a message to provide improved code.
It has been improved and compatible with Chrome. The following code has been modified to the latest version
The source code is available

Copy the code The code is as follows :




js gets div edit box, textarea, input The cursor position of text, compatible with FF and IE



< /head>

style="display: block" />

one two threefour five 六七八Ninety Note that there cannot be line breaks between the opening and closing tags of the source code, otherwise the statistics will be wrong! Note that there are other tags nested in the source code of the div edit box, and the correct position can be returned normally!



one two three four five SixSeventy-eight



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