[英]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.
让我们举个例子:-我有一个文本区域,其值JAVASCRIPT是客户端编程语言。
<textarea>JAVASCRIPT IS A CLIENT SIDE PROGRAMMING LANGUAGE</textarea>
My Fiddle: http://jsfiddle.net/83ogr3t8/ 我的小提琴: http : //jsfiddle.net/83ogr3t8/
Is there any way through which i can get the position of last word that i typed in textarea . 有什么办法可以让我获得在textarea中键入的最后一个单词的位置。 I don't want to use any plugin for this , it would be better if thing can be done with JavaScript only.
我不想为此使用任何插件,如果只能使用JavaScript完成操作会更好。 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/ http://jsfiddle.net/83ogr3t8/1/
function getLastPosition(){
var str = document.getElementById("myTextarea").value;
var strLeng = str.substr().length-1;
console.log(strLeng);
}
getLastPosition();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.