JS中文本框获得焦点后,光标位置如何跳到文本末尾
<script language="javascript">
function setFocus()
{
var obj = event.srcElement;
var txt =obj.createTextRange();
txt.moveStart('character',obj.value.length);
txt.collapse(true);
txt.select();
}
</script>
<input type="text" value="abcdefg123456789" onfocus="setFocus()">