JS使用replace替换字符串中的某段或某个字符

函数的介绍参考:http://www.w3school.com.cn/jsref/jsref_replace.asp

 

下列代码将Hello World!中的World替换为Jim

<html>
<body>

<script type="text/javascript">

var str="Hello World!"
document.write(str.replace("World","Jim"))

</script>
</body>
</html>
posted @ 2014-11-03 14:51  Waichung  阅读(1505)  评论(0编辑  收藏  举报