实现字母转换

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>
<body>
<div>
  <button onclick="pot1()">点击</button>
  <p>Paul,Paula,Pauline,paul,Paul</p>
  <p id="pot">Paul,Paula,Pauline,paul,Paul</p>
  <script type="text/javascript">
  function pot1(){
    var str="Paul,Paula,Pauline,paul,Paul";
    var text=str.replace(/\bPaul\b/g,"Ringo");
    document.getElementById("pot").innerHTML=text;
  }
  </script>
</div>
</body>
</html>
posted @ 2018-10-23 19:59  星光之晨  阅读(124)  评论(0编辑  收藏  举报