[英]How to get textarea's cursor move to the end of the highlighted text on drag and drop?
[英]how to get text in between cursor start and end of textarea
如何在html页面中textarea的光标开始和结束之间获取文本。
有人可以帮我吗,我已经搜索过了,但是没有找到任何相关的答案。
任何功能,例如游标开始和游标结束。
可以使用以下内容吗
var selection = rangy.getSelection(), // Whole lot of information, supports
// multi-selections too.
start = selection.anchorOffset, // Start position
end = selection.focusOffset; // End position
<textarea cols="50" rows="10" id="tarea"></textarea>
<button id="btn">get text</button>
$('#btn').on('click',function(){
cursor = $('#tarea').prop("selectionStart");
area = $('#tarea');
console.log(area.val().substring(cursor,area.val().length));
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.