티스토리 뷰
// 만약 jQuery를 사용한다면 아래의 사용자정의 trim(str) 대신 jQuery.trim(str) 사용
function trim(str) {
return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
String.prototype.trim = function() {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
// textarea 내용을 문장별 태그 지정하여 HTML로 반환
function getTextareaHTML(textareaId) {
return "
"+ document.getElementById(textareaId).value.trim().replace(/\n\r?/g,"
") +"
";
}
document.Write( getTextareaHTML("content") );
'웹프로그래밍 > js' 카테고리의 다른 글
| JavaScript 정규표현식 (0) | 2011.10.06 |
|---|---|
| jQuery 이용 json 으로 폼 값 입력 (0) | 2011.08.25 |
| jQuery UI Sortable dropOnEmpty 유의사항 (1) | 2011.06.07 |
| 커서위치에 글자 삽입 스크립트 (0) | 2011.06.01 |
| jQuery UI Dialog 에 따로 존재하는 html 페이지 로딩 (0) | 2011.05.18 |
댓글
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- git
- CSS
- IOS
- ASP
- IE
- 안드로이드
- Debug
- API
- Mac
- centos
- PHP
- Linux
- macos
- Android
- iis
- Prototype
- nodejs
- mssql
- classic asp
- javascript
- Wordpress
- nginx
- iphone
- 한글
- JQuery
- JSON
- sencha touch
- Docker
- laravel
- 워드프레스
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 29 |
| 30 |
글 보관함