textarea光标移到末尾兼容ie,ffchrome
function moveEnd(obj){
obj.focus();
var len = obj.value.length;
if (document.selection) {//ie识别
var sel = obj.createTextRange();
sel.moveStart('character',len);
sel.collapse();
sel.select();
} else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
obj.selectionStart = obj.selectionEnd = len;//ff和chrome
}
obj.focus();
var len = obj.value.length;
if (document.selection) {//ie识别
var sel = obj.createTextRange();
sel.moveStart('character',len);
sel.collapse();
sel.select();
} else if (typeof obj.selectionStart == 'number' && typeof obj.selectionEnd == 'number') {
obj.selectionStart = obj.selectionEnd = len;//ff和chrome
}
}
仅仅用调用方法。传进去对象就可以,jquery演示样例:moveEnd($(".moreComment textarea")[0]);