W3School TIY Editor
W3School 在线教程
改变方向
暗黑模式
运行代码
<!DOCTYPE html> <html> <body> <h2>JavaScript 字符串搜索</h2> <p>检查字符串是否包含 "world":</p> <p id="demo"></p> <p>Internet Explorer 不支持 includes() 方法。</p> <script> let text = "Hello world, welcome to the universe."; document.getElementById("demo").innerHTML = text.includes("world", 12); </script> </body> </html>