HTML DOM Textarea 열은 HTML 문서에 있는 텍스트 영역 요소의 col 속성 값을 반환하고 수정합니다.
구문
다음은 구문입니다 -
1. 열 반환
object.cols
2. 열 추가
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> 출력

"열 설정 =50을 클릭합니다. ” 버튼을 눌러 cols 속성 값을 50으로 설정합니다.
