cols 属性设置或返回文本框的字符列的宽度。
textareaObject.cols=number_of_columns
下面的例子更改的文本框的宽度:
<html>
<head>
<script type="text/javascript">
function changeCols()
{
document.getElementById('txt1').cols="20";
}
</script>
</head>
<body>
<textarea id="txt1">
Hello world....This is a text area
</textarea>
<br />
<input type="button" onclick="changeCols()" value="Change width" />
</body>
</html>