JQuery InsertAtCaret Function Hereを見つけましたが、使用方法の詳細はありません。どのように使用できるかを理解するために多くのことを試みましたが、方法が見つかりませんでした。これが関数です。
$.fn.insertAtCaret = function(myValue) {
return this.each(function() {
var me = this;
if (document.selection) { // IE
me.focus();
sel = document.selection.createRange();
sel.text = myValue;
me.focus();
} else if (me.selectionStart || me.selectionStart == '0') { // Real browsers
var startPos = me.selectionStart, endPos = me.selectionEnd, scrollTop = me.scrollTop;
me.value = me.value.substring(0, startPos) + myValue + me.value.substring(endPos, me.value.length);
me.focus();
me.selectionStart = startPos + myValue.length;
me.selectionEnd = startPos + myValue.length;
me.scrollTop = scrollTop;
} else {
me.value += myValue;
me.focus();
}
});
};
テキストボックス入力フィールドとその下にテキストエリアがあります。この関数をどこで呼び出す必要があり、どの値を指定する必要がありますか。そして、テキストエリアの参照を指定する必要がある場所。