<!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>

相关文章:

  • 2022-12-23
  • 2022-02-09
  • 2021-09-28
  • 2022-12-23
  • 2021-10-04
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-17
  • 2022-03-05
  • 2021-12-31
  • 2021-05-17
相关资源
相似解决方案