cols HTML DOM Textarea atribuyen
Definición y Uso
cols conjuntos de propiedades o devuelve el ancho de columna carácter de cuadro de texto.
gramática
Configuración cols atributos:
textareaObject.cols="number"
Volver cols atributos:
textareaObject.cols
值 | 描述 |
---|---|
number | 指定文本框的宽度。默认为20。 |
Soporte para el navegador
Todos los principales navegadores soportan el atributo cols
Ejemplos
Ejemplos
El ejemplo siguiente cambia el ancho del cuadro de texto:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
var textarea=document.getElementById("myTextarea");
textarea.cols=document.getElementById("myInput").value;
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>
<p>设置 cols 属性值:<input type="text" id="myInput" value="60">
<button type="button" onclick="displayResult()">修改 cols 属性</button></p>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult()
{
var textarea=document.getElementById("myTextarea");
textarea.cols=document.getElementById("myInput").value;
}
</script>
</head>
<body>
<textarea id="myTextarea" cols="20">
在本教程,你可以学多很多编程的基础知识,包括 HTML, XML, SQL, ASP, 和 PHP 等各种前端内容。
</textarea>
<br>
<p>设置 cols 属性值:<input type="text" id="myInput" value="60">
<button type="button" onclick="displayResult()">修改 cols 属性</button></p>
</body>
</html>
objeto textarea