<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
<title></title>
</head>
<body>
<script type="text/javascript">
var name=" linux ";
function trim(strs){
return strs.replace(/(^s*)|(s*$)/g,""); //使用js正则表达式方法
}
alert(trim(name).length);
$(function(){
alert($.trim(name).length);//使用jquery的$.trim()方法
})
</script>
</body>
</html>