js光标定位操作

1. 自动选中区域内容

<html>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>自动选择文本框/编辑框中的文字</title>
<script type="text/javascript">
    function Myselect_txt(){
        if (document.form1.title.focus){
        document.form1.title.select();}
    }
    function Myselect_txtarea(){
        if (document.form1.content.focus){
        document.form1.content.select();}
    }
</script>


<form name="form1">
    <input name="title" type="text" size="50" value="今日新闻头条" onClick="Myselect_txt()">
    <textarea name="content" cols="50" rows="6" onClick="Myselect_txtarea()">今日,据相关方面报道,...</textarea>
 </form>

</html>

 参考(先占位,后面再补充):https://blog.csdn.net/mafan121/article/details/78519348

posted @ 2019-09-08 13:32  AlexOne  阅读(2750)  评论(0)    收藏  举报