replace替换,全局和局部替换

<script>
var a=document.getElementById("introduce").innerHTML;
var b=a.replace(/jone/i,"toni");   //局部替换字符
var b=a.replace(/jone/g,"toni");   //全部替换字符
document.getElementById("introduce").innerHTML=b;
</script>
<p id="introduce">
jone,你好,你再;jone,你多大了
</p>

 

posted @ 2017-06-27 14:24  放荡不羁的春天  阅读(507)  评论(0编辑  收藏  举报