切换布局
显示结果
<html> <head> <title>JavaScript String Method</title> </head> <body> <p>点击按钮查看是否包含要查找的字符串,找到的话返回 true,否则返回 false。</p> <button onclick="myFunction()">点我</button> <p id="demo"></p> <p><strong>注意:</strong> IE 11 及更早版本不支持 includes() 方法 。</p> <script> function myFunction() { var str = "Hello world, welcome to the Runoob."; var n = str.includes("world", 12); document.getElementById("demo").innerHTML = n; } </script> </body> </html>