<textarea name="ta1" rows=5 cols=50>
aaaaaaaaaaaaaa
cccccccccc
dddddddddddd
fffffffffffff
</textarea>
<input value="1" name="line">
<input type=button onclick="goL(parseInt(line.value));" value="go">
<script>
function goL(Line)
{
ta1.focus();
var v=ta1.value.split('\n');
ch=0;
for(var i=0;i<Line-1;i++)
ch+=v[i].length;
var o=ta1.createTextRange();
o.move("character",ch);
o.select();
}
</script>
aaaaaaaaaaaaaa
bbbbbbbbbbbbbb
cccccccccc
dddddddddddd
fffffffffffff
[Ctrl+A 全选 注:如需引入外部Js需刷新才能执行]
时间: 2024-09-22 16:14:02