티스토리 뷰
// html code
<textarea data-autoresize rows="2"></textarea>
// javascript code
jQuery.each(jQuery('textarea[data-autoresize]'), function() {
var offset = this.offsetHeight - this.clientHeight;
var resizeTextarea = function(el) {
jQuery(el).css('height', 'auto').css('height', el.scrollHeight + offset);
};
jQuery(this).on('keyup input', function() { resizeTextarea(this); }).removeAttr('data-autoresize');
});
// css code
textarea {
box-sizing: border-box;
resize: none;
}
리사이징이 너무 잘되도록 어떤 외쿡 형님이 작성해놔서 숟가락만 얹었다....
'Javascript' 카테고리의 다른 글
간단하게 날짜 포맷 변경해보기 (0) | 2018.06.20 |
---|---|
history.pushState 사용하기 (0) | 2017.07.07 |
cookie 핸들링 해보기 (0) | 2017.01.24 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- Coordinator
- AssociatedObject
- Cleancode
- UIBarButtonItem
- RECORDING
- Video
- ssh
- UIControl
- NIB
- permission error
- Swift
- Realm
- AVKit
- carousel
- m3u8
- xib
- UIButton
- testing
- customAlertView
- AVFoundation
- database
- IOS
- pagingView
- HLS
- TDD
- Closure
- Design Pattern
- CollectionView
- BaseViewController
- http live streaming
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함