1

The question is sort of self explanatory. I'm trying to get the index of an specific text inside of a div after the user selects it with the mouse, so I can store it on a database. The idea is to retrieve that record from the database and wrap that text in a span tag using the index stored.

Thanks!

Kenshou
  • 95
  • 1
  • 2
  • 9
  • Any code that you have tried? – dowomenfart Feb 23 '15 at 20:15
  • Yes, I THINK i'm in the right direction by using window.getSelection().getRangeAt(0); but i'm not sure which of the elements from a Range object can help me to achieve what i'm trying to do. – Kenshou Feb 23 '15 at 20:19
  • http://stackoverflow.com/questions/1335252/how-can-i-get-the-dom-element-which-contains-the-current-selection – Amr Elgarhy Feb 23 '15 at 20:20
  • @AmrElGarhy that will give the the DOM element which contains the current selection, but not the index of the text itself – Kenshou Feb 23 '15 at 20:27

0 Answers0