js去掉前后空格
2011-10-13 12:14
211 查看
转:http://blog.myspace.cn/e/403615071.htm
js实现TRIM功能
一切皆有可能 发布于:2006-08-29 16:36
<SCRIPT LANGUAGE="JavaScript">
<!--
//出处:网上搜集
// Trim() , Ltrim() , RTrim()
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "");
}
String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, "");
}
//-->
</SCRIPT>
<input type="text" value=" 前后都是空格 " id="space">
<input type="button" value="去前后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.Trim();document.getElementById('space').select();">
<input type="button" value="去前空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.LTrim();document.getElementById('space').select();">
<input type="button" value="去后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.RTrim();document.getElementById('space').select();">
<input type="button" value="还原" onclick="javascript:document.getElementById('space').value=' 前后都是空格 ';">
去掉所有的空格
url=game_name.replace(/( )/g,"-").toLowerCase()+"-cd-key-gametime-card.html"
js实现TRIM功能
一切皆有可能 发布于:2006-08-29 16:36
<SCRIPT LANGUAGE="JavaScript">
<!--
//出处:网上搜集
// Trim() , Ltrim() , RTrim()
String.prototype.Trim = function()
{
return this.replace(/(^\s*)|(\s*$)/g, "");
}
String.prototype.LTrim = function()
{
return this.replace(/(^\s*)/g, "");
}
String.prototype.RTrim = function()
{
return this.replace(/(\s*$)/g, "");
}
//-->
</SCRIPT>
<input type="text" value=" 前后都是空格 " id="space">
<input type="button" value="去前后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.Trim();document.getElementById('space').select();">
<input type="button" value="去前空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.LTrim();document.getElementById('space').select();">
<input type="button" value="去后空格" onclick="javascript:document.getElementById('space').value=document.getElementById('space').value.RTrim();document.getElementById('space').select();">
<input type="button" value="还原" onclick="javascript:document.getElementById('space').value=' 前后都是空格 ';">
去掉所有的空格
url=game_name.replace(/( )/g,"-").toLowerCase()+"-cd-key-gametime-card.html"
相关文章推荐
- js去掉前后空格
- js去掉前后空格
- 去掉文本框前后的空格(JS+JQuery)
- js去掉前后空格的方法
- js去掉字符串前后空格
- js 去掉字符串前后空格
- js 去掉字符串前后空格
- js 去掉字符串前后空格
- js去掉字符串前后空格的五种方法
- JS(去掉前后空格或去掉所有空格)的用法
- js去掉前后空格
- js 去掉字符串前后空格
- js去掉字符串前后空格
- js 去掉字符串前后所有空格
- JS去掉字符串前后空格、阻止表单提交的实现代码
- JS(去掉前后空格或去掉所有空格)的用法
- js去掉字符串前后空格的五种方法
- JS(去掉前后空格或去掉所有空格)的用法
- JS(去掉前后空格或去掉所有空格)的用法
- JS中去掉字符串前后/左/右 空格