1

I can only get the cursor position of input and textarea elements, but how do I do this with div elements that contain contenteditable = "true"?

getCursor() {
      const text = this.$refs.test;
      const value = text.selectionStart;
      console.log(value); // result is undefined
    }
<div
  ref="test"
  contenteditable="true"
  :v-html="inputIntegrationHMTL"
  @input="getCursor($event)"
 > </div>
wesley S
  • 11
  • 1
  • 2
  • 1
    Does this answer your question? [selectionStart and selectionEnd in contenteditable element](https://stackoverflow.com/questions/19288700/selectionstart-and-selectionend-in-contenteditable-element) – DeveloperExceptionError Jan 26 '21 at 15:26

1 Answers1

-1

Like this?

getCursor(event) {
      console.log(event); // you can read pos here
}
<div
  ref="test"
  contenteditable="true"
  :v-html="inputIntegrationHMTL"
  @mouseover="getCursor($event)"
 > </div>
Endre Szabó
  • 554
  • 3
  • 9