Javascript examples for String:indexOf
Find the first occurrence of the letter "e" in a string, starting the search at position 5:
<!DOCTYPE html> <html> <body> <button onclick="myFunction()">Test</button> <p id="demo"></p> <script> function myFunction() {/*w w w . ja v a2 s . c om*/ var str = "Hello world, welcome to the universe."; var n = str.indexOf("e", 5); document.getElementById("demo").innerHTML = n; } </script> </body> </html>