简体   繁体   中英

How to get the last word position in textarea

As the title suggests how can i get the position of text in textarea. Lets take an example:- I have a textarea with the value JAVASCRIPT IS A CLIENT SIDE PROGRAMMING LANGUAGE.

<textarea>JAVASCRIPT IS A CLIENT SIDE PROGRAMMING LANGUAGE</textarea>

My Fiddle: http://jsfiddle.net/83ogr3t8/

Is there any way through which i can get the position of last word that i typed in textarea . I don't want to use any plugin for this , it would be better if thing can be done with JavaScript only. Please help me i am really stuck finding the answer for this question. I meant that i want to get top and left position of the text

I found a few libraries that might help you :

Hope these help. I think the only option you have now are these.

http://jsfiddle.net/83ogr3t8/1/

function getLastPosition(){
   var str = document.getElementById("myTextarea").value;
   var strLeng = str.substr().length-1;
   console.log(strLeng);
}

getLastPosition();

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM