//引入jQuery.js
var select = function(){
return window.getSelection ? window.getSelection().toString() : document.selection.createRange();
};
// 获取光标位置
function getCursortPosition(textDom) {
console.log(textDom);
var cursorPos = 0;
if (document.selection) {
// IE Support
var selectRange = document.selection.createRange();
selectRange.moveStart ('character', -textDom.value.length);
cursorPos = selectRange.text.length;
}else if (textDom.selectionStart || textDom.selectionStart*1 === 0) {
// Firefox support
cursorPos = textDom.selectionStart;
}
return cursorPos;
}
// 设置光标位置
function setCaretPosition(textDom, pos){
if(textDom.setSelectionRange) {
// IE Support
textDom