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>
Like this?
getCursor(event) { console.log(event); // you can read pos here }
<div ref="test" contenteditable="true":v-html="inputIntegrationHMTL" @mouseover="getCursor($event)" > </div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.