1

As I understood, selectionStart must return start position from selected text in input text or textarea elements

I have this js code

 $("#inpt").on("mouseup" , function () {
    alert( $("#inpt").selectionStart);
});

and html

<input id="inpt" type="text" value="bla bla bla" />

When I select some part in text "bla bla bla" the result is "undefined". Yell please, where did I go wrong ?

sideshowbarker
  • 81,827
  • 26
  • 193
  • 197
Oto Shavadze
  • 40,603
  • 55
  • 152
  • 236

1 Answers1

3

Try this.selectionStart, it's not the property of jQuery object, but the HTMLInputElement's property.

$("#inpt").on("mouseup" , function () {
    console.log(this.selectionStart);
});
xdazz
  • 158,678
  • 38
  • 247
  • 274