<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>测试</title>
</head>
<script type="text/javascript">
function on_click(){
var str = "你的我的它的";
alert(replaceAll(str,/(的)/g, ""));
}
function replaceAll(str,reg1,reg2){
return str.replace(reg1,reg2);//你我它
}
</script>
<body >
<input type="button" onclick="on_click()" value="点我"/>
</body>
</html>
js实现"replaceAll"效果
最新推荐文章于 2017-05-02 09:39:00 发布