[英]Replace the javascript code in html by javascript
我正在尝试用javascript替换html中的javascript代码
所以我正在测试像这样。
var test = new String("<script type=\"text/javascript\"> test </script>");
test.replace(/<script type=\"text\/javascript\">.+<\/script>/g,"");
//this doesn't match
console.log(test.toString());
test.replace不匹配,console.log显示此信息(什么都没有发生!)
<script type="text/javascript"> test </script>
有什么错误吗?
test.replace
返回替换的字符串,它不替换test
到位。
另请参阅https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/String/replace
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.