首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > JavaScript >

javascript replaceAll 步骤

2012-09-15 
javascriptreplaceAll方法htmlbodyscript/**方法一String.prototype.replaceAll function(s1,s2){

javascript replaceAll 方法
<html>
<body>

<script>
/**
方法一
String.prototype.replaceAll = function(s1,s2){
return this.replace(new RegExp(s1,"gm"),s2);
}
var t="a and b and f";
alert(t.replaceAll("and","or"));
*/


//方法二
var h="a and b and f";
alert(h.replace(/and/g,"or"));

</script>
</body>
</html>

热点排行