1

So I know you can get the position of the cursor in a textarea by using element.selectionStart and element.selectionEnd. Is there a way to do something similar with <code>?

(I'm trying to color text written by the user. As it seems, you can only change a whole textarea's color, not certain parts. I'm using <code contenteditable="true"> to try and fix that, but it seems to remove the possibility of reading the cursors position)

agrm
  • 3,735
  • 4
  • 26
  • 36
dtpnftscdsatp
  • 273
  • 1
  • 11
  • Any code you have tried? In one project I use contenteditables and I can get/set the cursor position without problems. – Jorge Fuentes González Aug 31 '19 at 13:13
  • Code Pen or JS Fiddle? – Ryan H Aug 31 '19 at 13:13
  • @RyanHolton — Please read [Something on my web site doesn't work. Can I just paste a link to it?](http://meta.stackoverflow.com/questions/125997/something-on-my-web-site-doesnt-work-can-i-just-paste-a-link-to-it). Questions that depend on external resources to be understood become useless when the external resource goes away or is fixed. The OP should create a [MCVE] and put it in **the question itself** instead. – Quentin Aug 31 '19 at 15:07

0 Answers0