replace替换
<!DOCTYPE html>
<html>
<body>
<button onclick="myFunction()">Try it<button>
<p id="demo">Paul,Paula,paul,sPaul,Paul,Paul</p>
<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var txt = str.replace(/Paul/g,"Ringo");
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<html>
<html>
<body>
<button onclick="myFunction()">Try it<button>
<p id="demo">Paul,Paula,paul,sPaul,Paul,Paul</p>
<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var txt = str.replace(/Paul/g,"Ringo");
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<html>