开发者

.replace() not working correctly

I have a string that i would like to convert.

the string is image and the content is: Gone in 60 seconds What i need is the following: Gone_in_60_seconds But when i try: image = image.replace(" ","_"); the result is: 开发者_如何学JAVAGone_in 60 seconds so only the first space gets replaced. How would i convert all the spaces to underscores?


Try this:

image = image.replace(/ /g, "_");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜