if you want to remove leading or trailing spaces, try str = str.replace(/^\s+|\s+$/g,""); if you want to remove all spaces, try str = str.replace(/\s+/g,""); |
|
来自: 冰红荼 > 《HTML&CSS&SCRIPT》