osfipin

JS去掉首尾空格 简单方法大全

var osfipin= \'       http://www.cnblogs.com/osfipin/  \';

//去除首尾空格
osfipin.replace(/(^\s*)|(\s*$)/g, "");

//去除左边空格
osfipin.replace(/(^\s*)/g, "");

//去除右边空格
osfipin.replace(/(\s*$)/g, "");

//jquery 需提前引用jquery
$.trim(osfipin);
//另一种写法
jQuery.trim(osfipin);

  

分类:

技术点:

相关文章:

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