zoukankan      html  css  js  c++  java
  • string method and regular expresions

    <!doctype html>
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8">
        <title>01 exam</title>
        <link rel="stylesheet" type="text/css" href="01 exam.css">
    </head>
    <body>
    
    <h2>JavaScript String Methods</h2>
    
    <p>Replace "Microsoft" with "W3Schools" in the paragraph below:</p>
    
    <button onclick="myFunction()">Try it</button>
    
    <p id="demo">paul,paula,pauline,panl,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>
  • 相关阅读:
    11.26
    数组
    JavaScript
    2018.11.26
    input标签
    HPH 函数
    jQuery
    19/1/3数组
    2018/12/26//循环体
    12/25
  • 原文地址:https://www.cnblogs.com/CheeseIce/p/9832414.html
Copyright © 2011-2022 走看看