Started

Selectors

Utilities

Animation

AJAX

CSS

Event

Manipulation

Cookie

String

Attributes

Data

Storage

Miscellaneous

$css.get

Remove the whitespace from the beginning and end of a string.
$string.trim( string )
  1. string [string]
    The target string.

Notes

Triming the string before submit to server will save more storage.

Example

HTML code
<div id="message"></div>
<button onclick="start_trim()">Trim the string</button>
CSS code
#box {
	width: 200px;
	height: 60px;
	font-size: 12px;
	background: #5599bb;
	padding: 10px;
}
JavaScript code
function start_trim()
{
	var data = "                               This is the original string with additional whitespace from start and end.                                   ";
	$html($("message"), $string.trim(data));
}
Demonstration