<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>JS--Demo</title>
<script language="javascript">
function trim(s){
return s.replace(/^\s*/,"").replace(/\s*$/,"");
}
function on(){
alert(trim("ddddddddddddd "));;
}
</script>
</head>
<body>
<input type="button" value="button" onclick="on()"/>
</body>
</html>
javascript去除空格
最新推荐文章于 2023-06-30 14:44:51 发布
本文提供了一个简单的JavaScript函数实现,用于删除字符串前后的空白字符。通过一个按钮触发的示例展示了如何使用该函数。
318

被折叠的 条评论
为什么被折叠?



