textarea
[JS] Textarea 높이 자동 조절
예제 코드 See the Pen Textarea Auto Height by hyukson (@hyukson) on CodePen. 코드 높이를 조절할 textarea 요소를 준비해줍니다. textarea { width: 240px; height: 30px; } textarea의 기본 Height를 지정해주고, 이 크기는 JavaScript 코드에서도 사용하게 됩니다. const DEFAULT_HEIGHT = 30; // textarea 기본 height const $textarea = document.querySelector('#textarea'); CSS에서 지정한 Height를 'DEFAULT_HEIGHT' 변수에 저장시켜줍니다. document.querySelector() 선택자로 textarea ..
![[JS] textarea 줄바꿈 갯수](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2FM5s47%2FbtrxY5aKWWh%2FVCkBR7KkAXtlGcKQObpkk0%2Fimg.png)
[JS] textarea 줄바꿈 갯수
코드 const rowsCount = (target) => { // 개수 console.log( target.value.split("\n").length - 1 ); } Enter를 입력 시 줄바꿈 되는 개행(\n)을 기준으로 잘라 개수를 셀 수 있습니다.