js的replace全部替换动态字符串

js的replace全部替换动态的字符串?

解决方法:

1.全部替换写死的字符串

var str="朋友的朋友";
var new_str="同学";
alert(str.replace(new RegExp(/朋友/g),new_str));

2.全部替换动态的字符串:http://www.yayihouse.com/yayishuwu/chapter/1602

猜你喜欢

转载自blog.csdn.net/qq_30908729/article/details/82817829