JavaScript一句话去除所有空格

使用正则表达式:

 

 

<% @ Page Language = " C# "  AutoEventWireup = " true "  CodeFile = " Default3.aspx.cs "  Inherits = " Default3 "   %>

<! 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  runat ="server" >
    
< title > Untitled Page </ title >
    
< script  type ="text/javascript" >
    
function  show()
    {
        
var  strValue = " this is a string without space "
        window.alert(strValue.replace(
/ \s+ / g,  '' ));
    }
    
</ script >
</ head >
< body  onload ="show();" >
    
< form  id ="form1"  runat ="server" >
    
< div >
    
    
</ div >
    
</ form >
</ body >
</ html >

你可能感兴趣的:(JavaScript)