Utilities - 양쪽 공백 제거 함수 : trim()
[Trim.htm]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>양쪽 공백 제거 함수 : trim()</title>
<script src="../js/jquery-1.3.2-vsdoc2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
var s = " Abc Def Fed Cba ";
alert("[" + s + "]");
alert(s.length);
alert("[" + $.trim(s) + "]"); // 양쪽 공백 제거
alert(jQuery.trim(s).length); // 17 - 2 = 15
});
</script>
</head>
<body>
</body>
</html>
-------------------------------------------------------------------------------------
[실행결과]