I was recently working on a comment feature that required the ability to comment on emoticons, so the First, comment on the district chief: When the input content exceeds the limit, clear the content after the user input exceeds the limit. This is easy... But after clearing the content, the cursor actually moved to the front, which is a headache. After various searches, I found a solution. Without further ado, here is the code! var _div = document.querySelector('.discuss_area'); var range = document.createRange(); range.selectNodeContents(_div); range.collapse(false); var sel = window.getSelection(); sel.removeAllRanges(); sel.addRange(range); All of them use native events, so This article is about solving the problem that when a div is set to contentEditable=true, the cursor cannot be positioned correctly after resetting its content. This is the end of the article. For more relevant content about div setting contentEditable=true, please search 123WORDPRESS.COM’s previous articles or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! |
<<: Common naming rules for CSS classes and ids
>>: Detailed explanation of CSS background and border tag examples
1. Parent components can use props to pass data t...
When Mysql associates two tables, an error messag...
Preface Introduction Lombok is a handy tool, just...
On a Linux computer, there are two times, one is ...
To execute a shell command in Docker, you need to...
Clickhouse Introduction ClickHouse is a column-or...
I am using centos 7 64bit system here. I have tri...
Description: Limit the number of lines of text di...
1. Environmental preparation: Operating system: C...
Event response refresh: refresh only when request...
Comprehensive understanding of html.css overflow ...
Note: The third method is only used in XSell and ...
The previous article introduced the implementatio...
This article shares the specific code of JavaScri...
It's the end of the year and there are fewer ...