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 ?

Mishax
  • 4,322
  • 5
  • 36
  • 63
Oto Shavadze
  • 37,634
  • 51
  • 140
  • 215

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
  • 154,648
  • 35
  • 237
  • 264