jQuery.trim()
jQuery.trim()은 문자열에 있는 공백(whitespace)을 제거합니다. 주의할 점은 문자열 앞과 뒤에 있는 공백은 제거하지만, 문자열 중간에 있는 공백은 제거하지 않는다는 것입니다.
기본형
jQuery.trim( str )
예제
두 번째 줄에 jQuery.trim()을 적용하였습니다.
<pre class="ab"></pre>
<pre class="cd"></pre>
$( document ).ready( function() {
var str = ' Lorem Ipsum dolor ';
$( '.ab' ).html( str );
$( '.cd' ).html( jQuery.trim( str ) );
});