AutoCAD 3DMAX C语言 Pro/E UG JAVA编程 PHP编程 Maya动画 Matlab应用 Android
Photoshop Word Excel flash VB编程 VC编程 Coreldraw SolidWorks A Designer Unity3D
 首页 > JavaScript

JS实现选择TextArea内文本的方法

51自学网 http://www.wanshiok.com
JS,选择,TextArea,文本

本文实例讲述了JS实现选择TextArea内文本的方法。分享给大家供大家参考。具体实现方法如下:

<script type="text/javascript">  function select_field(id){    document.getElementById(id).focus();    document.getElementById(id).select();  }  function init(){    select_field('text1');  }  onload=init;</script><form>This field gets selected onload:<br/><input type="text" name="text1" id="text1" value="some text" /><br/><textarea name="textarea1" id="textarea1" rows="9" cols="50" wrap="off">Some longcontent in here.abcd efgh abcd efgh abcd efghabcd efgh abcd efgh abcd efghabcd efgh abcd efgh abcd efgh</textarea><br/><input type="button" value="Select text" onclick="select_field('textarea1')"></form>

希望本文所述对大家的javascript程序设计有所帮助。


JS,选择,TextArea,文本  
上一篇:javascript实现随机读取数组的方法  下一篇:Javascript连接Access数据库完整实例