发布:2023/12/7 15:39:58作者:大数据 来源:大数据 浏览次数:502
Uncaught TypeError:replaceAll is not a function
原因是浏览器内核版本不支持这个替换方法。可以必胜javascript方法进行字符串替换操作
用js替换首个字符用str.replace("abc","")
全局替换需要用到正则表达式了:
1 2 3 4 5 6 7 |
<script type="text/javascript"> var str="Welcome to Microsoft! " str=str + "We are proud to announce that Microsoft has " str=str + "one of the largest Web Developers sites in the world." document.write(<code>str.replace(/Microsoft/g, "W3School")</code>) </script> |
忽略大小写调用:原字符串.replace(/待替换字串/gi,"新字符串")
参考:
https://www.w3school.com.cn/jsref/jsref_replace.asp
© Copyright 2014 - 2025 柏港建站平台 ejk5.com. 渝ICP备16000791号-4