Регистрация или ->Экспорт данныхПоиск
Войти
Экспорт:
Папки

/var_null/yaziki-programmirovaniya/html/textarea
Не экспортировать закрытые директории
Преобразовывать заметки в html
Экспортировать
Удалить директорию
Применить
 Стили директорииДобавить заметку
Вставить текст на место курсора в textarea
2018-06-19 21:42:50 Удалить Фон Изображение Импорт из текстового файла Редактировать Копировать в буфер
function insertTextAtCursor(el, text, offset) {
    var val = el.value, endIndex, range, doc = el.ownerDocument;
    if (typeof el.selectionStart == "number"
            && typeof el.selectionEnd == "number") {
        endIndex = el.selectionEnd;
        el.value = val.slice(0, endIndex) + text + val.slice(endIndex);
        el.selectionStart = el.selectionEnd = endIndex + text.length+(offset?offset:0);
    } else if (doc.selection != "undefined" && doc.selection.createRange) {
        el.focus();
        range = doc.selection.createRange();
        range.collapse(false);
        range.text = text;
        range.select();
    }
}

insertTextAtCursor(document.getElementById('textareaid'),'Привет');
Похожие разделы:
->var_null:root/Пользователи/var_null/Языки программирования/html/textarea/ (текущий раздел)
Участвуй в наполнении сайта, создай свое дерево знаний. Регистрация

@include_encode 2015