How do I use JavaScript to change the position of a cursor and then place new content at it?
- 阅读更多 关于 How do I use JavaScript to change the position of a cursor and then place new content at it?
问题 I am using JavaScript to create a very simple code that inserts bulletin board codes into a textarea when you click on a button. The code I wrote works ok, however, I would like to be able to place the new tags at the cursor instead of at the end of the text, and then keep the cursor in the middle of the new tags. For example: currently, when a user clicks b, then u, then s, it displays as [b][/b][u][/u][s][/s] . I would like to be able to do something like [b][u][s]^[/s][/u][/b] where ^ is