function locatePoint(){ var aCtrl = document.getElementById("txtContent"); if (aCtrl.setSelectionRange) { setTimeout(function() { aCtrl.setSelectionRange(0, 0); //将光标定位在textarea的开头,需要定位到其他位置的请自行修改 aCtrl.focus(); }, 0); }else if (aCtrl.createTextRange) { var textArea=document.getElementById("txtContent"); var tempText=textArea.createTextRange(); tempText.moveEnd("character",0-tempText.text.length); tempText.select(); } }