strBirthday = strBirthday.replace(/\//g,"-");// 将/替换为- 亲测:replace方法会返回替换后的字符串,但不会改变原字符串,若有需要可直接赋值。测试过程如下: 测试.png