[Vuejs]-How to get selectionStart and selectionEnd properties of v-textarea in VueJS?

1👍

$refs.vta only returns the v-textarea element, which is a wrapper element containing its own refs which includes the inner <textarea> input element. You can access the inner element to get selectionStart and selectionEnd like so:

this.start = this.$refs.vta.$refs.input.selectionStart;
this.end = this.$refs.vta.$refs.input.selectionEnd;

sandbox example

👤yoduh

Leave a comment