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