textarea 높이 질문 채택완료

textarea에 입력할때 처음 높이보다 내용이 많으면 스크롤이 생기는데

 

이걸 입력하는 양에 따라서 자동으로 높이가 커지게 가능한가요?

답변 1개

채택된 답변
+20 포인트

Copy
$(document).on('input','textarea',function () {
        var $this = $(this);
        if(!this.org_h){
            this.org_h = $this.outerHeight();
        }

        if(this.scrollHeight<this.org_h){
            return true;
        }

        this.style.height = 'auto';
        this.style.height = (this.scrollHeight) + 'px';
    })
로그인 후 평가할 수 있습니다

댓글을 작성하려면 로그인이 필요합니다.

답변을 작성하려면 로그인이 필요합니다.

로그인
🐛 버그신고