运行 ❯
获取您
自己
的网站
×
更改方向
保存代码
更改主题,深色/浅色
前往 Spaces
<!DOCTYPE html> <html> <body> <h1>JavaScript Strings</h1> <h2>The indexOf() Method</h2> <p>The indexOf() method accepts a second parameter as the starting position for the search:</p> <p id="demo"></p> <script> let text = "Please locate where 'locate' occurs!"; let index = text.indexOf("locate",15); document.getElementById("demo").innerHTML = index; </script> </body> </html>