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