源代码
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>享学课堂</title> </head> <body> <p>用"享学课堂" 替换 "2xkt.com":</p> <button onclick="myFunction()">试试</button> <p id="demo">请访问2xkt.com!</p> <script> function myFunction() { var str = document.getElementById("demo").innerHTML; var txt = str.replace(/2xkt.com/i,"享学课堂"); document.getElementById("demo").innerHTML = txt; } </script> </body> </html>
运行结果