JS实现选择TextArea内文本的方法
作者:不吃皮蛋 时间:2024-04-16 10:40:02
本文实例讲述了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 long
content in here.
abcd efgh abcd efgh abcd efgh
abcd efgh abcd efgh abcd efgh
abcd efgh abcd efgh abcd efgh
</textarea>
<br/>
<input type="button" value="Select text" onclick="select_field('textarea1')">
</form>
希望本文所述对大家的javascript程序设计有所帮助。
标签:JS,TextArea
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
escape解决AJAX中文乱码的简单方法
2008-10-23 14:32:00
python3中rank函数的用法
2022-09-26 07:00:45
用Python实现给Word文档盖章
2021-07-08 21:18:00
![](https://img.aspxhome.com/file/2023/3/93463_0s.jpg)
vue使用ElementUI时导航栏默认展开功能的实现
2024-05-09 15:18:14
Python 经典面试题 21 道【不可错过】
2023-10-29 04:56:20
Pytorch实现图像识别之数字识别(附详细注释)
2022-04-08 08:12:54
![](https://img.aspxhome.com/file/2023/1/134581_0s.jpg)
10个糟糕的IE Bug及其修复
2010-05-13 16:26:00
![](https://img.aspxhome.com/file/UploadPic/20105/13/01-19s.gif)
Python利用matplotlib做图中图及次坐标轴的实例
2022-01-06 18:14:56
![](https://img.aspxhome.com/file/2023/8/104898_0s.jpg)
史上最详细的Python打包成exe文件教程
2021-07-19 06:30:16
![](https://img.aspxhome.com/file/2023/9/108039_0s.png)
教大家使用Python SqlAlchemy
2022-12-02 01:40:17
Python竟能画这么漂亮的花,帅呆了(代码分享)
2021-02-04 15:50:00
![](https://img.aspxhome.com/file/2023/7/82577_0s.jpg)
mybatis+mysql 使用存储过程生成流水号的实现代码
2024-01-18 11:09:56
![](https://img.aspxhome.com/file/2023/8/69838_0s.png)
深入理解Python分布式爬虫原理
2023-02-06 14:33:30
![](https://img.aspxhome.com/file/2023/8/66458_0s.jpg)
python基础教程之lambda表达式使用方法
2022-12-21 19:10:19
css基础教程属性篇之二
2008-07-25 19:23:00
![](https://img.aspxhome.com/file/UploadPic/20087/25/2008725192720609s.jpg)
SQL 存储过程基础语法之一
2024-01-26 19:58:05
探讨SQL利用INFORMATION_SCHEMA系统视图如何获取表的主外键信息
2024-01-23 04:16:36
![](https://img.aspxhome.com/file/2023/0/121240_0s.jpg)
让Dreamweaver MX显示最舒服的编程环境
2008-02-25 14:01:00
![](https://img.aspxhome.com/file/UploadPic/20082/25/200822514442940s.jpg)
基于prototype扩展的JavaScript常用函数库
2023-08-24 15:09:57
Anaconda下Python中GDAL模块的下载与安装过程
2022-08-30 04:49:54
![](https://img.aspxhome.com/file/2023/8/82928_0s.png)