Latest web development tutorials

HTML DOM Textarea cols atribut

Textarea Referensi Obyek objek textarea

Definisi dan Penggunaan

cols set properti atau mengembalikan kotak teks kolom karakter lebar.

tatabahasa

Pengaturan cols atribut:

textareaObject.cols="number"

Kembali cols atribut:

textareaObject.cols

描述
number 指定文本框的宽度。默认为20。


Dukungan Browser

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Semua browser utama mendukung cols atribut


contoh

contoh

Contoh berikut mengubah lebar kotak teks:

<!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>



Textarea Referensi Obyek objek textarea