将文本中的Paul替换为Runoob
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="cover.css">
</head>
<body>
<button onclick="myFunction()">点我</button>
<p id="demo">Paul,Paula,paul,sPaul,Paul</p>
<script>
function myFunction() {
var str = document.getElementById("demo").innerHTML;
var txt = str.replace(/\bPaul\b/g,"Runoob");
document.getElementById("demo").innerHTML = txt;
}
</script>
</body>
<html>