function addData(Value){ // 光标处输入
var $t = $('textarea[name="comment"]')[0]; // 插入值所在的input框
if (document.selection) {
$t.focus();
sel = document.selection.createRange();
sel.text = Value;
$t.focus();
} else if ($t.selectionStart || $t.selectionStart == '0') {
var startPos = $t.selectionStart;
var endPos = $t.selectionEnd;
var scrollTop = $t.scrollTop;
$t.value = $t.value.substring(0, startPos) + Value + $t.value.substring(endPos, $t
.value.length);
$t.focus();
$t.selectionStart = startPos + Value.length;
$t.selectionEnd = startPos + Value.length;
$t.scrollTop = scrollTop;
} else {
this.value += Value;
$t.focus();
}
}
点击备选文字插入光标处
最新推荐文章于 2024-04-18 11:15:48 发布