div位置在文本区域之外,用于在文本区域中多选文本?

时间:2018-01-29 13:04:02

标签: javascript jquery css

我面临着在文本区域中多次选择文本的问题,div被放置在文本区域之外,但对于单个选择单词,它工作正常..

JavaScript的:

$(document).ready(function () {
closePopUp();
var newpost = $('#newpost');
$('#mytextarea').on('select', function (e) {
    var txtarea = document.getElementById("mytextarea");
    var start = txtarea.selectionStart;
    var finish = txtarea.selectionEnd;
    newpost.offset(getCursorXY(txtarea, start, 20)).show();
    newpost.find('div').text('replace with stars');
});
document.onkeydown = undo;

});

这是我的plunker

问题如下图所示:

enter image description here

0 个答案:

没有答案
相关问题