HTML DOM Textarea cols 属性
HTML DOM Textarea cols 返回和修改 HTML 文档中文本区域元素的 cols 的属性值。
语法
语法如下 −
1. 返回 cols
object.cols
2. 添加 cols
object.cols = “number”
我们来看看 HTML DOM Textarea cols 属性的一个示例
示例
<!DOCTYPE html>
<html>
<style>
body {
color: #000;
background: lightseagreen;
height: 100vh;
}
.btn {
background: #db133a;
border: none;
height: 2rem;
border-radius: 2px;
width: 40%;
display: block;
color: #fff;
outline: none;
cursor: pointer;
}
</style>
<body>
<h1>DOM Textarea cols Property Demo</h1>
<textarea>Hi! I'm a textarea element in an HTML document with some dummy text.</textarea>
<button onclick="set()" class="btn">Set Cols = 50</button>
<script>
function set() {
document.querySelector("textarea").cols = '50';
}
</script>
</body>
</html>输出

点击 “设置Cols = 50” 按钮,将 cols 属性的值设置为 50。

广告
数据结构
网络
关系型数据库管理系统
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
JavaScript
PHP