如何设置textarea光标默认为第一行第一个字符
直接设置下鼠标事件onmousedown就可以的
<body>
<script>
function s(e,a)
{
if ( e && e.preventDefault )
e.preventDefault();
else
window.event.returnValue=false;
a.focus();
}
</script>
<textarea id="anan" onmousedown="s(event,this)"></textarea>
</body>
</html>
本文介绍了一种通过JavaScript实现的方法,使得在textarea中加载页面时,默认光标位置自动定位到第一行的第一个字符处。该方法利用了onmousedown事件来触发光标的定位。

310

被折叠的 条评论
为什么被折叠?



